The OpenAI Batch API allows you to submit up to 50,000 requests in a single JSONL file and receive results within 24 hours at 50% reduced cost. Master the vocabulary for batch file format, job lifecycle, error handling, and custom_id correlation.
0 / 5 completed
1 / 5
An engineer uploads a .jsonl file with 60,000 request lines to the OpenAI Batch API. What happens?
The OpenAI Batch API enforces a hard limit of 50,000 requests per batch file. Submitting a file with more lines causes an immediate 400 validation error. You must split the workload across multiple batch jobs.
2 / 5
A batch job enters status: 'failed' after 20 minutes. The engineer checks output_file_id — it is null. Where should they look for individual request errors?
When a batch job fails at the request level (not the whole job), OpenAI writes per-line error records to a separate file referenced by error_file_id. The errors.data array on the batch object lists job-level validation errors, not per-request failures.
3 / 5
What is the maximum completion window accepted by the completion_window parameter when creating a batch?
The only accepted value for completion_window is 24h. OpenAI guarantees that all requests in the batch will complete within 24 hours. The parameter exists as an enum for potential future expansion.
4 / 5
An engineer wants to correlate each output line back to its source request. Which field in the input .jsonl line is echoed verbatim in the output .jsonl?
Every input line must contain a custom_id string (max 64 chars). This identifier is echoed in the corresponding output line, allowing deterministic mapping of results back to source requests even when output order differs from input order.
5 / 5
A team runs 1 million gpt-4o-mini completions daily via the standard Chat Completions endpoint. Switching to Batch API offers what pricing advantage?
The OpenAI Batch API offers a 50% cost reduction compared to synchronous API calls. This makes it highly cost-effective for offline workloads like dataset generation, embeddings, and bulk classification that tolerate up to 24-hour latency.