Skip to main content
The Batch API runs a file of requests asynchronously, for work that doesn’t need an immediate answer: classifying a catalog or generating descriptions. You upload a JSONL file with one request per line, create a batch, and download a results file when it completes, within 24 hours. It follows OpenAI’s Batch API.
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.
1

Prepare the input file

Each line of the file is one request, with a 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
Input files may be up to 200 MB.
2

Upload the file

Request bodies are capped at 4.5 MB, so files are uploaded straight to storage through a presigned URL:
  1. Call POST /v1/files with the file’s purpose, filename, and size in bytes. No file bytes are sent in this call. It returns a file id and a short-lived upload_url.
  2. PUT the file to the upload_url. The URL is already signed, so this call carries no API key.
3

Create the batch

Call POST /openai/v1/batches with the uploaded file’s id:
As in OpenAI’s API, problems in the file’s contents don’t fail this request. The batch is created and lands in status failed with an errors list, for example when lines use different models (model_mismatch) or a model you can’t call.
4

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.
5

Download the results

A completed batch has an 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.
You can also follow batches and download their files on the Batches page of Liquid Console.