Skip to main content
POST
/
batches
Create a batch
curl --request POST \
  --url https://api.sailresearch.com/v1/batches \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "endpoint": "/v1/responses",
  "label": "my-batch-job",
  "requests": [
    {
      "custom_id": "my-first-request",
      "params": {
        "model": "zai-org/GLM-5.2-FP8",
        "max_output_tokens": 1024,
        "input": [
          {
            "role": "user",
            "content": "Hello, world!"
          }
        ]
      }
    },
    {
      "custom_id": "my-second-request",
      "params": {
        "model": "zai-org/GLM-5.2-FP8",
        "max_output_tokens": 1024,
        "input": [
          {
            "role": "user",
            "content": "Hello again!"
          }
        ]
      }
    }
  ]
}
'
import requests

url = "https://api.sailresearch.com/v1/batches"

payload = {
"endpoint": "/v1/responses",
"label": "my-batch-job",
"requests": [
{
"custom_id": "my-first-request",
"params": {
"model": "zai-org/GLM-5.2-FP8",
"max_output_tokens": 1024,
"input": [
{
"role": "user",
"content": "Hello, world!"
}
]
}
},
{
"custom_id": "my-second-request",
"params": {
"model": "zai-org/GLM-5.2-FP8",
"max_output_tokens": 1024,
"input": [
{
"role": "user",
"content": "Hello again!"
}
]
}
}
]
}
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({
endpoint: '/v1/responses',
label: 'my-batch-job',
requests: [
{
custom_id: 'my-first-request',
params: {
model: 'zai-org/GLM-5.2-FP8',
max_output_tokens: 1024,
input: [{role: 'user', content: 'Hello, world!'}]
}
},
{
custom_id: 'my-second-request',
params: {
model: 'zai-org/GLM-5.2-FP8',
max_output_tokens: 1024,
input: [{role: 'user', content: 'Hello again!'}]
}
}
]
})
};

fetch('https://api.sailresearch.com/v1/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://api.sailresearch.com/v1/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([
'endpoint' => '/v1/responses',
'label' => 'my-batch-job',
'requests' => [
[
'custom_id' => 'my-first-request',
'params' => [
'model' => 'zai-org/GLM-5.2-FP8',
'max_output_tokens' => 1024,
'input' => [
[
'role' => 'user',
'content' => 'Hello, world!'
]
]
]
],
[
'custom_id' => 'my-second-request',
'params' => [
'model' => 'zai-org/GLM-5.2-FP8',
'max_output_tokens' => 1024,
'input' => [
[
'role' => 'user',
'content' => 'Hello again!'
]
]
]
]
]
]),
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://api.sailresearch.com/v1/batches"

payload := strings.NewReader("{\n \"endpoint\": \"/v1/responses\",\n \"label\": \"my-batch-job\",\n \"requests\": [\n {\n \"custom_id\": \"my-first-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, world!\"\n }\n ]\n }\n },\n {\n \"custom_id\": \"my-second-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello again!\"\n }\n ]\n }\n }\n ]\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://api.sailresearch.com/v1/batches")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"endpoint\": \"/v1/responses\",\n \"label\": \"my-batch-job\",\n \"requests\": [\n {\n \"custom_id\": \"my-first-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, world!\"\n }\n ]\n }\n },\n {\n \"custom_id\": \"my-second-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello again!\"\n }\n ]\n }\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sailresearch.com/v1/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 \"endpoint\": \"/v1/responses\",\n \"label\": \"my-batch-job\",\n \"requests\": [\n {\n \"custom_id\": \"my-first-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, world!\"\n }\n ]\n }\n },\n {\n \"custom_id\": \"my-second-request\",\n \"params\": {\n \"model\": \"zai-org/GLM-5.2-FP8\",\n \"max_output_tokens\": 1024,\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello again!\"\n }\n ]\n }\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "batch_abc123",
  "request_counts": 2,
  "created_at": 1741564800,
  "label": "my-batch-job"
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}
{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Idempotency-Key
string

Makes the request retry-safe. Sail stores a reservation keyed by (organization, API key, Idempotency-Key); retrying with the same value returns the previously stored response instead of re-running inference. Keys are capped at 255 characters. See Idempotent Requests for full semantics.

Maximum string length: 255

Body

application/json
endpoint
enum<string>
required

The API endpoint to use for all requests in the batch. Currently only /v1/responses is supported.

Available options:
/v1/responses
requests
object[]
required

The list of requests in the batch. Min 1, max 100,000 requests. Total request body must not exceed 256 MB.

Required array length: 1 - 100000 elements
label
string

An optional label for the batch. Must be alphanumeric (hyphens and underscores allowed), max 128 characters.

Maximum string length: 128
Pattern: ^[a-zA-Z0-9_-]+$

Response

Batch created.

id
string
required

Unique identifier for the batch.

request_counts
integer
required

Total number of requests in the batch.

created_at
integer
required

Unix timestamp of when the batch was created.

label
string

The label for the batch, if provided.