Batches

The OpenAI Batch API shape for asynchronous jobs, settled line by line.

Upload the input file

Write one request per JSONL line with a unique custom_id, method, url (the batch endpoint) and body. The model in each body must be a batch model: a slug ending in -batch (for example gpt-6-luna-batch). Set max_tokens to a positive integer within the model's output limit. Upload with purpose: "batch", up to 110 MiB.

POST/v1/files
{"custom_id": "q1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-6-luna-batch", "max_tokens": 256, "messages": [{"role": "user", "content": "Summarize document 1"}]}}
{"custom_id": "q2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-6-luna-batch", "max_tokens": 256, "messages": [{"role": "user", "content": "Summarize document 2"}]}}

Create and poll the batch

Submit with the file id and the same endpoint as the lines. Poll until it finishes, then download output_file_id (and error_file_id). Cancel with POST /v1/batches/{batch_id}/cancel.

POST/v1/batchesGET/v1/batches/{batch_id}GET/v1/files/{file_id}/content
import time

b = client.batches.create(input_file_id=f.id, endpoint="/v1/chat/completions", completion_window="24h")
while b.status not in ("completed", "failed", "expired", "cancelled"):
    time.sleep(30)
    b = client.batches.retrieve(b.id)
if b.output_file_id:
    print(client.files.content(b.output_file_id).text)

Rules

TopicBehavior
BillingEach line settles as its own usage row attributed to the submitting key
Not servedGET /v1/files (list) and DELETE /v1/files/{id}
Data controlsrequire_zdr, require_no_training and provider allowlists apply at submit and again before dispatch; a failing batch is 400 provider_policy before any hold. A batch cannot carry a per-request ZDR constraint
Region restrictionOrganizations with a processing-region restriction cannot use batches
Not accepted on linesgateway.retry / gateway.routing, guardrail policies

See Data controls and batch pricing.

POST/v1/batches/{batch_id}/cancel
curl -X POST https://api.experientiallabs.ai/v1/batches/BATCH_ID/cancel \
  -H "Authorization: Bearer YOUR_API_KEY"