Overview
The Batch API allows you to submit multiple API requests in a single batch for asynchronous processing. Batches offer 50% cost savings and a separate pool of significantly higher rate limits.Create batch
Creates and executes a batch from an uploaded file of requests.Parameters
The ID of an uploaded file containing requests for the batch. Each line must be a valid JSON object with:
custom_id- Your identifier for the requestmethod- HTTP method (currently onlyPOST)url- The endpoint pathbody- Request parameters
The API endpoint for all requests in the batch. Currently supported:
/v1/responses- Responses API/v1/embeddings- Embeddings API
Time frame for processing. Currently only
24h is supported.Optional metadata (up to 16 key-value pairs)
Expiration policy for output/error files
Response
Returns aBatch object:
Unique batch identifier
Current status:
validating, failed, in_progress, finalizing, completed, expired, cancelling, or cancelledID of the input file
ID of the output file (available when completed)
ID of the error file (if any requests failed)
Request counts by status:
Retrieve batch
Retrieves a batch by ID.Parameters
The ID of the batch to retrieve
List batches
Lists your organization’s batches.Parameters
Number of objects to return (1-100, default: 20)
Cursor for pagination
Cancel batch
Cancels an in-progress batch. The batch will move tocancelling status for up to 10 minutes before becoming cancelled.
Parameters
The ID of the batch to cancel