Supported endpoints
| Endpoint | Description |
|---|---|
/v1/chat/completions | Chat completion requests |
/v1/embeddings | Embedding generation |
/v1/images/generations | Image generation |
Lifecycle
A batch moves through these statuses:| Status | Description |
|---|---|
validating | The input file is being checked for format and content errors. |
failed | Validation failed — the input file contains errors. Check batch.errors for details. |
in_progress | Requests are being processed. |
finalizing | All requests have been processed and the output files are being generated. |
completed | The batch finished. Download results from output_file_id. |
cancelling | A cancel was requested. In-flight requests are finishing. |
cancelled | The batch was cancelled. Partial results may be available. |
expired | The batch did not complete within the 24-hour window. |
Step 1 — Prepare the input file
Create a JSONL file where each line is one request. Every line has four fields:| Field | Type | Description |
|---|---|---|
custom_id | string | Your identifier for this request. Used to match input to output. Must be unique within the file. |
method | string | "POST" — the only supported method. |
url | string | The endpoint path — must match the endpoint you declare when creating the batch. |
body | object | The request body — the same parameters you would send to the synchronous endpoint. |
Step 2 — Upload the input file
Upload the JSONL file using the Files API withpurpose: "batch".
Step 3 — Create the batch
Pass the uploaded file ID, the target endpoint, and the completion window.Step 4 — Check batch status
Poll the batch until it reaches a terminal status.Step 5 — Download the results
Once the batch iscompleted, download the output file. It is a JSONL file where each line contains the custom_id you provided, the response, and any error.
response is null and error contains the details:
error_file_id containing only the failed entries.
Cancel a batch
Cancel a batch that is still in progress. Requests that have already completed remain in the output.cancelling while in-flight requests finish, then to cancelled.
List batches
Retrieve all batches for the current account, newest first. Supports pagination.after parameter with a batch ID to page through results.
Example: batch embeddings
The same flow works for embeddings. Change theurl in each JSONL line and the endpoint when creating the batch.
Validation errors
If the input file has formatting issues, the batch moves tofailed immediately.
Common causes:
- Invalid JSON — a line is not valid JSON.
- Missing fields — a line is missing
custom_id,method,url, orbody. - Wrong method —
methodmust be"POST". - URL mismatch — the
urlin a line does not match theendpointdeclared when creating the batch. - Duplicate
custom_id— eachcustom_idmust be unique within the file.
batch.errors.data for the specific error messages and line numbers.
See also
- Generate a response for the synchronous chat completions pattern.
- Files and vector stores for the Files API used to upload batch inputs.