Kolkata ·  
AI engineering
workflows
short · 3 min

Batch API

Send many requests as one job, get the results back within a day (often within the hour), pay half.

updated 29 Sept 2026

It's evening, and we want to rerun our eval set of 2,000 questions against a new model before tomorrow. Nobody is sitting there waiting for any one answer. We just want all 2,000 by morning.

Sending them one by one through the normal chat API works. But both Anthropic and OpenAI have a cheaper door for exactly this kind of job: a batch API. We hand over all the requests as one job, and the results come back later. As of 2026-09, both charge half the normal price for it.

Handing over the job

Each of the 2,000 is an ordinary request: model, messages, max_tokens. The batch just bundles them, and each one gets a custom_id we choose, like eval-0042.

On OpenAI the list goes into a JSONL file, one request per line, which we upload first; on Anthropic it goes straight into the create call. Then we check the batch's status every so often until it's done. On Anthropic it goes from in_progress to ended; most batches finish in under an hour. Both give it a 24-hour window.

When it's done, we fetch the results and join them to our requests by custom_id. That join matters, because results can come back in any order. If we'd matched on position, we'd have scored question 17 against the answer to question 912 and never noticed.

AnthropicOpenAI
Pricehalf of standardhalf of standard
Size limit100,000 requests or 256 MB50,000 requests or 200 MB
Results kept29 daysoutput deleted 30 days after it finishes

What we give up is speed and back-and-forth. There's no streaming; results come back as a file. And we're promised an answer within the window, not a fast one. That's why the batch API is for eval runs, backfills and bulk classification or extraction, and the live API is for anything a person is waiting on.

On OpenAI there's a second perk: batch requests draw from a separate pool of rate limits, so a big job overnight doesn't eat the limits our live traffic needs.

The morning after

So it's morning. What might we find?

Some requests may not have finished. Anything not done in 24 hours expires, and when demand is high, processing slows and more of them do. On OpenAI, an expired batch still hands back the requests that completed (and bills for them). So we collect the missing ids and send them again.

Some may have failed. One bad request doesn't sink the batch. On Anthropic each result is succeeded, errored, canceled or expired, and only the first is billed. Our code has to handle all four.

And here's the annoying one. On Anthropic, each request's parameters are only checked once the whole batch has run. A typo in the request shape means we find out after the wait, not before. Sending one request through the normal API first catches that for the price of one call.

What about prompt caching? If all 2,000 requests share the same long system prompt, caching and the batch discount do stack. But requests in a batch run at the same time and in any order, so cache hits are best effort, anywhere from 30% to 98% depending on traffic. Keeping the shared part identical in every request helps. So does the 1-hour cache, since a batch can easily outlast the default 5-minute one. How much that saves on our 2,000 questions is something we'd only know by looking at the usage numbers once it's done.

Further reading

  • Batch processing, Anthropic, undated. Limits, result types, prices per model, and how caching behaves inside a batch.
  • Batch API, OpenAI, undated. The JSONL format, which endpoints it covers, and what happens when a batch expires.