When would you use a batch API, and how do you design a pipeline around one?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Batch APIs (OpenAI Batch, Anthropic Message Batches) accept a file/list of requests, process them asynchronously with a completion window of up to ~24 h (often much faster in practice), and charge ~50% of interactive pricing. The provider is selling you their off-peak/spare capacity; you're selling them scheduling flexibility. Batch jobs also typically draw on separate, much larger quota than your interactive rate limits - so they stop background work from cannibalising your production TPM.
Full worked answer
Batch APIs (OpenAI Batch, Anthropic Message Batches) accept a file/list of requests, process them asynchronously with a completion window of up to ~24 h (often much faster in practice), and charge ~50% of interactive pricing. The provider is selling you their off-peak/spare capacity; you're selling them scheduling flexibility. Batch jobs also typically draw on separate, much larger quota than your interactive rate limits - so they stop background work from cannibalising your production TPM.
Use it for anything without a user waiting: eval suites, embeddings/classification backfills, document summarization pipelines, data enrichment and labelling, synthetic-data generation, content moderation sweeps, nightly report generation, re-processing after a prompt change. A shocking fraction of many teams' token spend is this shape and silently paying interactive prices. Never use it for user-facing latency-bound paths - and for the middle ground ("results within minutes"), you still need the interactive API.
Pipeline design points:
- Idempotent request identity: attach your own
custom_idper request; results return keyed by it, unordered. Make re-submission safe (dedupe on custom_id) because you will resubmit. - Chunk jobs into bounded batches (both providers cap requests/bytes per batch) and track job state in a durable store: submitted → in_progress → completed/expired/failed.
- Handle partial outcomes: individual requests inside a batch can fail or the window can expire with a subset done - reconcile per-request, resubmit only the missing/failed, with a retry cap.
- Poll or webhook for completion; on completion, download results, validate (schema-check outputs), then commit downstream.
- Combine with the other cost levers: prompt caching applies to batch traffic too on some providers; dedupe identical requests before submission.
- Backpressure: a batch pipeline that fans out from user actions needs a queue with rate control so a spike doesn't create a million-request batch storm.
What a good answer covers
- Batch APIs (OpenAI Batch, Anthropic Message Batches) accept a file/list of requests, process them…
- The provider is selling you their off-peak/spare capacity; you're selling them scheduling flexibility
- Batch jobs also typically draw on separate, much larger quota than your interactive rate limits - so…
- Use it for anything without a user waiting
- A shocking fraction of many teams' token spend is this shape and silently paying interactive prices
Key terms: ~50% of interactive pricing · Idempotent request identity · Chunk jobs · Handle partial outcomes · Poll or webhook · Backpressure
In the glossary: Batch API · Prompt caching
Interviewer follow-ups to expect
How do you handle a batch that comes back 2% failed?
Your nightly batch now needs 4-hour freshness - what changes?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep