All pages

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

  1. Pick a :batch model from the catalogue. 2. Send endpoint (/v1/chat/completions or /v1/embeddings), model and a requests array; each request has a unique custom_id and a body that is the normal request body (no stream). 3. The 202 reply carries a batch_… id. 4. Poll GET /v1/batches/{id} every 30-60 seconds: validating → in_progress → finalizing → completed. 5. Each entry in results has custom_id, status_code and body (the normal endpoint's response) or error. 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.

POST/v1/batchesBearer auth

Create 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

FieldinTypeDescription
Idempotency-Keyheaderstring

Optional deduplication token (any string up to 200 characters).

How it works:

  • Same key + same request body → cached response replayed (safe retry)
  • Same key + different body → 409 CONFLICT error
  • Keys expire after 24 hours

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

FieldTypeDescription
endpointrequiredstring

The endpoint every request in the batch runs against.

Allowed values: /v1/chat/completions · /v1/embeddings

modelrequiredstring

A :batch model id from the catalogue (for example openai/gpt-6-luna:batch). The bare id is accepted too. One model for the whole batch.

Example: openai/gpt-6-luna:batch

requestsrequiredarray of object

Up to 1,000 requests. Each custom_id must be unique.

custom_idrequiredstring

Your id for this request; results are matched by it.

bodyrequiredobject

The same body you would send to endpoint. model may be omitted (it must match the batch model if present); stream is not supported.

Example

Responses

202

Batch accepted.

400

The 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: the tools array, plugins field, or model's :online suffix uses an unsupported shape. The response names the offender and links to the supported form. See the dedicated InvalidTools response 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.format value 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_audio content part sent to POST /v1/responses. The Responses API has no audio content type today; resend to POST /v1/chat/completions instead.
401

Authentication 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"
  }
}
402

Not enough credit to hold the batch's estimated cost.

404

The requested resource was not found. Either the ID is wrong or it belongs to a different account.

429

Too many requests. Back off and retry after a short delay. Check the Retry-After header for guidance.

503

The 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.

GET/v1/batchesBearer auth

List batches

Your batches, newest first, without results.

Parameters

FieldinTypeDescription
limitqueryinteger
afterquerystring

The last_id of the previous page.

Example

Responses

200

A page of batches.

401

Authentication 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"
  }
}
GET/v1/batches/{id}Bearer auth

Get 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

FieldinTypeDescription
idrequiredpathstring

Example

Responses

200

Current batch state.

401

Authentication 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"
  }
}
404

The requested resource was not found. Either the ID is wrong or it belongs to a different account.

429

Too many requests. Back off and retry after a short delay. Check the Retry-After header for guidance.

503

The 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.

DELETE/v1/batches/{id}Bearer auth

Delete 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

FieldinTypeDescription
idrequiredpathstring

Example

Responses

200

Deleted.

401

Authentication 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"
  }
}
404

The requested resource was not found. Either the ID is wrong or it belongs to a different account.

409

Idempotency key conflict: you sent the same Idempotency-Key with a different request body.

503

The 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 :batch for 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 completed and request_counts.failed shows how many failed. Each failed entry in results carries an error and is not charged.

Updated 2026-11-25