POST /api/v1/batch or batch.create. Return all results together or stream them as they finish.
cURL
Request
Send an
Idempotency-Key header so a retried batch replays instead of running twice. A streamed batch can’t be replayed — reusing its key returns 409 stream_not_replayable.
Response
results is ordered by index. Each job keeps the same silent model-fallback chain a single chat request has, so model is the model that actually served the job and requested_model is the one you asked for. A success result carries usage_estimated: true when the provider didn’t report usage and the tokens were estimated. balance_warning appears when your balance is at or below $5.
Streaming
Withstream: true the response is text/event-stream. Each finished job arrives as a data: frame with type: "result" and the same fields as above; a final type: "summary" frame carries succeeded, failed, total_cost_cents, total_cost, and request_id, followed by data: [DONE].
Billing and limits
- Hold, then settle. Before any job runs, the gateway holds the sum of every job’s metered maximum (input estimate plus
max_tokensat that model’s rates). Each successful job bills its actual metered usage at the serving model’s rates; failed jobs cost nothing; the unused hold is refunded when the batch completes. If your balance can’t cover the hold you get402 insufficient_creditswithestimated_costandbalance; a project or key spend limit returns402 spend_limit_exceeded. - Rate limits. A batch of N jobs consumes N units of the chat requests-per-minute and concurrency budgets and the summed token estimate of the tokens-per-minute budget, so it draws on the same 60-per-minute-per-key pool as
/chat/completions. A429from this route addsunits(the fan-out size). See Rate limits. - Body size. The whole request must fit the batch route’s JSON limit; keep long documents to a few jobs per call.
Compare models
One prompt, several models, ranked results.
Spend controls
Estimate holds before you send.