The Batch API is enabled per organization, and each model must support it. Until it is enabled, creating a batch returns
403 with code batch_api_not_enabled. Contact us to request access.Prepare the input file
Each line of the file is one request, with a Input files may be up to 200 MB.
custom_id you choose to match results to requests, the method, the endpoint url, and the request body. Every line must target the same endpoint and the same model. Supported endpoints are /v1/chat/completions and /v1/completions.batch_input.jsonl
Upload the file
Request bodies are capped at 4.5 MB, so files are uploaded straight to storage through a presigned URL:
- Call
POST /v1/fileswith the file’spurpose,filename, and size inbytes. No file bytes are sent in this call. It returns a file id and a short-livedupload_url. PUTthe file to theupload_url. The URL is already signed, so this call carries no API key.
Create the batch
Call As in OpenAI’s API, problems in the file’s contents don’t fail this request. The batch is created and lands in status
POST /openai/v1/batches with the uploaded file’s id:failed with an errors list, for example when lines use different models (model_mismatch) or a model you can’t call.Check the status
Poll
GET /openai/v1/batches/{id} until the batch finishes. request_counts shows the total, completed, and failed requests so far.A batch that fails validation ends as failed. Cancel a running batch with POST /openai/v1/batches/{id}/cancel. A batch still running after its 24-hour window ends as expired. Expired and cancelled batches still return the results of the requests that finished.Download the results
A completed batch has an You can also follow batches and download their files on the Batches page of Liquid Console.
output_file_id, and an error_file_id if any requests failed. Download each with GET /openai/v1/files/{id}/content. Each line of the output is one result, with the custom_id of its request, so match results to requests by custom_id.