Save 50% on Batch Processing
Batch API offers 50% cost savings compared to standard API calls. Perfect for processing large volumes of requests asynchronously.
Free Tier Limitation: Batch API is only available for Basic tier and above. Upgrade your plan to unlock batch processing.
Create a new batch job for asynchronous processing of multiple API requests.
The ID of an uploaded file that contains the requests for this batch. The file must be uploaded with purpose="batch" and be in valid JSONL format.
The endpoint to be used for all requests in the batch. Currently supported endpoints:
/v1/chat/completions - For chat completion requests
/v1/embeddings - For embedding generation
/v1/responses - For response generation
The time frame within which the batch should be processed. Currently only 24h is supported.
Optional custom metadata for the batch. Can contain any key-value pairs for tracking purposes.
Returns
A unique identifier for the batch job (e.g., batch-abc123).
The object type, which is always batch.
The API endpoint that will be used for all requests in the batch.
Any errors encountered during batch processing. Will be null if no errors.
The ID of the input file containing batch requests.
The time window for batch completion.
The current status of the batch. Possible values:
validating - The input file is being validated
in_progress - The batch is being processed
finalizing - The batch is being finalized
completed - The batch has completed successfully
failed - The batch has failed
expired - The batch has expired
canceled - The batch was canceled
The ID of the file containing successful batch results. Available when status is completed.
The ID of the file containing failed requests. Available when there are errors.
The Unix timestamp (in seconds) of when the batch was created.
The Unix timestamp when the batch started processing.
The Unix timestamp when the batch will expire.
The Unix timestamp when the batch started finalizing.
The Unix timestamp when the batch completed.
The Unix timestamp when the batch failed.
The Unix timestamp when the batch expired.
The Unix timestamp when cancellation was initiated.
The Unix timestamp when the batch was cancelled.
Statistics about the requests in the batch.Show request_counts properties
Total number of requests in the batch.
Number of requests that completed successfully.
Number of requests that failed.
Custom metadata associated with the batch.
{
"id": "batch-abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-xyz789",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1699564800,
"in_progress_at": null,
"expires_at": 1699651200,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": {
"total": 100,
"completed": 0,
"failed": 0
},
"metadata": {
"project": "data-analysis",
"batch_type": "daily_processing"
}
}