Skip to main content

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 The body is parsed as newline-delimited JSON regardless of content-type. You can send a single JSON object (one item) or a multi-line JSONL file. JSONL line schema Each line must be a JSON object with these top-level fields:
string
required
A unique identifier for this item, assigned by you. Returned as-is in the output so you can match results to inputs.
string
required
Always "POST".
string
required
Always "/v1/chat/completions".
object
required
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"

string
required
The input text to extract entities from.
object
required
A map of entity label → plain-English description. Keys become entity type values in the response.
string
Optional additional instructions appended to the extraction prompt.

"model": "summarize"

string
required
The input text to summarize.
string
Optional additional rules appended to the base summarization prompt (e.g. "Use bullet points.", "Focus on financial figures only.").
number
default:20048
Maximum tokens in the generated summary.

"model": "classify"

string
required
The input text to classify.
array
required
Array of label objects. Each object must have:
  • name (string) — the label name
  • rubric (string) — a yes/no question describing what this label means
string
Optional additional instructions for the classification model.

Limits A single batch may contain at most 50 requests. Submitting more returns 400. Split larger workloads across multiple batches.

Response

Returns an OpenAI-compatible Batch object. A newly created batch starts in "validating".

Get batch status

GET /v1/batches/{batch_id}

Poll this endpoint until status is "completed" or "failed". Returns the same OpenAI-compatible Batch object.
status is one of validating, in_progress, completed, or failed. An unknown batch ID returns 404.

Get batch output

GET /v1/batches/{batch_id}/output

Returns a JSONL file where each line corresponds to one input item.
string
The custom_id you provided in the input.
object | null
The response object. null if the item failed.
  • status_code — HTTP status of the individual item
  • body — ChatCompletion-shaped object. The domain result is JSON-serialized in choices[0].message.content.
object | null
Error details if the item failed. null on success.
Parsing the domain result:

Error responses


Examples

Submit a mixed batch

Response:

Poll for completion


Retrieve and parse output

Sample output JSONL: