Create Batch
curl --request POST \
--url https://{gatewayBaseURL}/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
'import requests
url = "https://{gatewayBaseURL}/batches"
payload = {
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input_file_id: 'file-PnFGrFLN5LjjcWr4eFsStK',
endpoint: '/v1/chat/completions',
completion_window: '24h'
})
};
fetch('https://{gatewayBaseURL}/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{gatewayBaseURL}/batches",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_file_id' => 'file-PnFGrFLN5LjjcWr4eFsStK',
'endpoint' => '/v1/chat/completions',
'completion_window' => '24h'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{gatewayBaseURL}/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{gatewayBaseURL}/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{gatewayBaseURL}/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_67f7bfc50b288190893f242d9fa47c52",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1764288000,
"in_progress_at": null,
"expires_at": 1764374400,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
}
}Batch
Create Batch
Creates a new batch processing job from an uploaded JSONL input file.
POST
/
batches
Create Batch
curl --request POST \
--url https://{gatewayBaseURL}/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
'import requests
url = "https://{gatewayBaseURL}/batches"
payload = {
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input_file_id: 'file-PnFGrFLN5LjjcWr4eFsStK',
endpoint: '/v1/chat/completions',
completion_window: '24h'
})
};
fetch('https://{gatewayBaseURL}/batches', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{gatewayBaseURL}/batches",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_file_id' => 'file-PnFGrFLN5LjjcWr4eFsStK',
'endpoint' => '/v1/chat/completions',
'completion_window' => '24h'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{gatewayBaseURL}/batches"
payload := strings.NewReader("{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{gatewayBaseURL}/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{gatewayBaseURL}/batches")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input_file_id\": \"file-PnFGrFLN5LjjcWr4eFsStK\",\n \"endpoint\": \"/v1/chat/completions\",\n \"completion_window\": \"24h\"\n}"
response = http.request(request)
puts response.read_body{
"id": "batch_67f7bfc50b288190893f242d9fa47c52",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-PnFGrFLN5LjjcWr4eFsStK",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1764288000,
"in_progress_at": null,
"expires_at": 1764374400,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
}
}Authorizations
Headers
Body
application/json
Batch processing parameters
Response
Batch created successfully
Was this page helpful?