Batches: bulk requests at about half price
Models whose id ends in :batch (for example openai/gpt-6-luna:batch) are the batch version of the same model: about half the price, but no instant answer. Send up to 1,000 chat or embeddings requests at once with POST /v1/batches, poll GET /v1/batches/{id} every minute, and once status is completed read the answers from results, matching them to your requests by custom_id. Most batches finish in minutes; the window is 24 hours.
When to use a batch
When you have a lot of work and no rush: classifying thousands of reviews, translating long texts, summarising documents, building search embeddings, or evaluating a model on a dataset. For live chat with a user, call /v1/chat/completions with the normal model.
How it works
- Pick a
:batchmodel from the catalogue. 2. Sendendpoint(/v1/chat/completionsor/v1/embeddings),modeland arequestsarray; each request has a uniquecustom_idand abodythat is the normal request body (nostream). 3. The202reply carries abatch_…id. 4. PollGET /v1/batches/{id}every 30-60 seconds:validating→in_progress→finalizing→completed. 5. Each entry inresultshascustom_id,status_codeandbody(the normal endpoint's response) orerror. Results come in no fixed order.
Billing
At submit, the estimated cost of the whole batch is held from your credit; when it finishes you are charged only its actual cost. Requests that fail are not charged; if the whole batch fails or expires, the hold is released. Set max_tokens on chat requests so the hold stays small.
Limits
Up to 1,000 requests and 50 MB per batch, one model and one endpoint per batch, and at most 10 batches running at once. A running batch cannot be cancelled; once it finishes you can remove it with DELETE /v1/batches/{id}. Results stay available for 30 days. Sending a :batch model to /v1/chat/completions returns 400 BATCH_MODEL_REQUIRES_BATCHES_API.
/v1/batchesBearer authCreate a batch
Submit up to 1,000 chat or embeddings requests for a :batch model.
Returns 202 at once with the batch id; results arrive within 24
hours (usually minutes).
Billing: the estimated cost of the whole batch is held from your
credit at submit, and you are charged the actual batch price when it
finishes. A batch that fails or expires releases the hold. Set
max_tokens on chat requests: without it each request is held at the
default completion limit.
A :batch model sent to /v1/chat/completions or /v1/embeddings
directly returns 400 BATCH_MODEL_REQUIRES_BATCHES_API.
Parameters
| Field | in | Type | Description |
|---|---|---|---|
Idempotency-Key | header | string | Optional deduplication token (any string up to 200 characters). How it works:
When to use: Add this header when you want to safely retry a request after a network timeout without risking a duplicate operation. |
Request bodyrequired
| Field | Type | Description |
|---|---|---|
endpointrequired | string | The endpoint every request in the batch runs against. Allowed values: |
modelrequired | string | A Example: |
requestsrequired | array of object | Up to 1,000 requests. Each |
custom_idrequired | string | Your id for this request; results are matched by it. |
bodyrequired | object | The same body you would send to |
Example
Responses
202Batch accepted.
400The request body or query parameters are invalid. Check the
error.code and error.message fields for details. Codes the
gateway emits at 400:
BAD_REQUEST: generic malformed JSON / missing required field.INVALID_TOOLS: thetoolsarray,pluginsfield, or model's:onlinesuffix uses an unsupported shape. The response names the offender and links to the supported form. See the dedicatedInvalidToolsresponse below for the three triggers and migration hints.UNSUPPORTED_TOOL: a built-in tool (file_search,code_interpreter,computer_use,mcp) whose pricing dimension is not yet wired into the gateway hold estimator.INVALID_AUDIO_FORMAT:input_audio.formatvalue is not in the supported set. The envelope lists every supported codec name. The gateway accepts both short names (wav,webm) and full MIME aliases (audio/wav,audio/webm); anything else fails fast at admission. See API guide §8b.AUDIO_NOT_SUPPORTED_ON_RESPONSES:input_audiocontent part sent toPOST /v1/responses. The Responses API has no audio content type today; resend toPOST /v1/chat/completionsinstead.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401,
"type": "authentication_error"
}
}402Not enough credit to hold the batch's estimated cost.
404The requested resource was not found. Either the ID is wrong or it belongs to a different account.
429Too many requests. Back off and retry after a short delay.
Check the Retry-After header for guidance.
503The upstream AI provider is temporarily
unavailable. Retry with exponential backoff (1s, 2s, 4s) using the
same Idempotency-Key: if the upstream actually completed
the work and only the response failed, the gateway replays the
cached success without a second charge. Holds are released
automatically on upstream failures.
/v1/batchesBearer authList batches
Your batches, newest first, without results.
Parameters
| Field | in | Type | Description |
|---|---|---|---|
limit | query | integer | |
after | query | string | The |
Example
Responses
200A page of batches.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401,
"type": "authentication_error"
}
}/v1/batches/{id}Bearer authGet a batch
Returns the batch's status. Once it has finished, results holds one
entry per request. Poll every 30-60 seconds; a batch takes minutes
to hours. Results stay available for 30 days.
Parameters
| Field | in | Type | Description |
|---|---|---|---|
idrequired | path | string |
Example
Responses
200Current batch state.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401,
"type": "authentication_error"
}
}404The requested resource was not found. Either the ID is wrong or it belongs to a different account.
429Too many requests. Back off and retry after a short delay.
Check the Retry-After header for guidance.
503The upstream AI provider is temporarily
unavailable. Retry with exponential backoff (1s, 2s, 4s) using the
same Idempotency-Key: if the upstream actually completed
the work and only the response failed, the gateway replays the
cached success without a second charge. Holds are released
automatically on upstream failures.
/v1/batches/{id}Bearer authDelete a batch
Deletes a finished batch and its results. A batch that is still
running cannot be cancelled or deleted (409 BATCH_NOT_FINISHED).
Parameters
| Field | in | Type | Description |
|---|---|---|---|
idrequired | path | string |
Example
Responses
200Deleted.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401,
"type": "authentication_error"
}
}404The requested resource was not found. Either the ID is wrong or it belongs to a different account.
409Idempotency key conflict: you sent the same Idempotency-Key with
a different request body.
503The upstream AI provider is temporarily
unavailable. Retry with exponential backoff (1s, 2s, 4s) using the
same Idempotency-Key: if the upstream actually completed
the work and only the response failed, the gateway replays the
cached success without a second charge. Holds are released
automatically on upstream failures.
FAQ
- Why doesn't a :batch model work on normal chat?
The batch version runs only in batches and has no instant answer. Send it through
POST /v1/batches, or call the same model without:batchfor an instant reply.- How long does a batch take?
Usually minutes; the window is 24 hours. A batch that does not finish in that time expires and its hold is released.
- What if some requests fail?
The batch still ends
completedandrequest_counts.failedshows how many failed. Each failed entry inresultscarries anerrorand is not charged.