Overview
The Batch API accepts the same request fields as the realtime endpoints. Set"model" to "extract", "summarize", or "classify" to select the operation. Each item is processed independently — a failure on one item does not affect others.
Documents (document / document_mime_type) are not supported in batch requests. Pass pre-extracted text in the text field.
Submit a batch
POST /v1/batches
Submit a JSONL body where each line is one request. Returns a batch ID to poll for status and output.
Request headers
| Header | Value |
|---|---|
content-type | application/jsonl (recommended) or application/json |
x-api-key | Your API key |
A unique identifier for this item, assigned by you. Returned as-is in the output so you can match results to inputs.
Always
"POST".Always
"/v1/chat/completions".The request body.
model is the discriminator — set it to "extract", "summarize", or "classify". Remaining fields depend on the model.Body fields by model
"model": "extract"
The input text to extract entities from.
A map of entity label → plain-English description. Keys become entity
type values in the response.Optional additional instructions appended to the extraction prompt.
"model": "summarize"
The input text to summarize.
Optional additional rules appended to the base summarization prompt (e.g.
"Use bullet points.", "Focus on financial figures only.").Maximum tokens in the generated summary.
"model": "classify"
The input text to classify.
Array of label objects. Each object must have:
name(string) — the label namerubric(string) — a yes/no question describing what this label means
Optional additional instructions for the classification model.
Response
Get batch status
GET /v1/batches/{batch_id}
Poll this endpoint until status is "completed" or "failed".
Get batch output
GET /v1/batches/{batch_id}/output
Returns a JSONL file where each line corresponds to one input item.
The
custom_id you provided in the input.The response object.
null if the item failed.status_code— HTTP status of the individual itembody— ChatCompletion-shaped object. The domain result is JSON-serialized inchoices[0].message.content.
Error details if the item failed.
null on success.Error responses
| Status | Meaning |
|---|---|
400 Bad Request | A JSONL line has an invalid model value or malformed JSON. |
401 Unauthorized | Missing or invalid x-api-key. |
503 Service Unavailable | Batch router is not configured. |
502 Bad Gateway | Upstream batch router request failed. |