# When Do You Use Batch APIs?

> When to send AI work as a batch, what it saves, and when it is the wrong tool, explained simply for your AI interview.

**In short:** Use a batch API when nobody is waiting on the answer: nightly evaluations, labelling a big dataset, or embedding a document store. You send many requests together, collect the answers within about a day, and pay about half the live price.

AI and LLM interview question Q331, Inference, performance and cost. Intermediate, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/when-do-you-use-batch-apis

## Say it in 30 seconds

Batch APIs are for work nobody is waiting on. I send many requests together, the provider runs them in its own time, and I collect the answers within a day. Both OpenAI and Anthropic charge about half the live price for it. So I use it for nightly evaluations, labelling big datasets and backfills. Anything a user waits for stays a normal live call.

## Say it in 2 minutes

A batch API is a way to send a large group of AI requests at once and get the answers later. A normal call waits for a reply in seconds. A batch is handed over, worked through in the provider's own time, and collected when it is done. Each request carries a custom ID, so I can match every answer back to its input.

I choose it by asking one question: does a person or a live screen wait for this reply? If yes, it is a live call. If no, it is a batch candidate. Nightly evaluations, bulk classification and embedding a document store all fit. OpenAI describes these same kinds of job as ones that do not need an immediate response.

The reasons are cost and room. Both OpenAI and Anthropic charge half the standard price for batch work. OpenAI also says batch jobs get more headroom on rate limits than live calls do. The price is time and flexibility. Results can take up to a day, they come back as one file rather than a stream, and each request is handled on its own.

In practice I would split a 300,000-chat nightly job into batches under the provider's size cap, keep a live path for anything a user needs now, and send failed rows to a smaller retry batch. I would also check that the batch finishes before the business needs the numbers.

## What is a batch API, in plain words?

A normal AI call is like standing at a counter. You ask, and you wait for the answer before you walk away. A batch API is like handing a pile of forms to a back office and collecting the results when they are ready. You send many requests together, the provider works through them, and you pick up the answers later.

- **Live call:** One request, one reply, sent back straight away. You wait for it.
- **Batch job:** Many requests sent together, processed later, with the results collected at the end.
- **Custom ID:** Your own label on each request, so you can match its answer to the right input.
- **Rate limit:** The cap on how many requests your account may send in a set time.

Here is a case with real stakes. A bank's support team wants every chat from the day tagged by complaint type, to spot a fault in a payment app. A live call per chat would be slow and cost full price. Running the whole day's chats as one overnight batch gives the same tags, at lower cost, and nobody waits on a screen.

## When do you use a batch API?

Use one when the work has no one waiting on it. Typical jobs are nightly evaluations of a model, classifying a large dataset, and embedding a company's whole document store. Both vendors describe the same kind of work, jobs that do not need an immediate response. OpenAI names running evaluations, classifying large datasets and embedding content repositories. Anthropic names large-scale evaluations and data analysis.

> "The service is ideal for processing jobs that don't require immediate responses." (OpenAI)
>
> "This approach is well-suited to tasks that do not require immediate responses" (Anthropic)

- **Good fit: Work that can wait.** Nightly evaluations, bulk classification, embedding a document store, or rerunning old data through a new prompt.
- **Poor fit: Anything a user waits for.** A chat reply, a payment check or a voice call. A batch can take up to a day, which is far too slow for these.

*Diagram, Pick the path with one question: One question picks the path: does a person or a live screen wait for the reply? If yes, use a live call. If nobody waits, use a batch, which costs about half and returns within a day.*
1. The job goes to the question: does anyone wait for the answer?
2. Yes: a live call, so the answer comes back in seconds.
3. No: a batch, which costs about half and returns within a day.

Cost is the main reason. Both OpenAI and Anthropic charge half the standard price for batch work. OpenAI also says batch jobs get more headroom on rate limits than live calls do, which matters when you must push a very large number of requests through.

## How does a batch job run, step by step?

Here is a nightly job of 300,000 chats. The size is made up, but a mid-size bank's support team could realistically face it.

1. **Build the requests:** Write one request per chat, each with its own custom ID and the same tagging instructions. Keep the shared instructions identical so they can be cached.
2. **Split into batches:** Anthropic caps one batch at 100,000 requests or 256 MB. So 300,000 chats need at least three batches.
3. **Submit and check:** Send each batch, then check its status now and then. It stays in progress until the provider has finished every request.
4. **Collect the results:** Match each answer to its chat by custom ID. Each result is succeeded, errored, cancelled or expired.
5. **Retry the failures:** Send errored rows in a smaller batch. Anthropic says errored requests are not billed.

> **Tip:** If the same long instructions go into every request, ask for a one-hour cache. Anthropic suggests it when processing batches with shared context, because batches can take longer than 5 minutes to process.

*Diagram, A nightly batch, end to end: A nightly job of 300,000 chats runs as a few batches. Each request has its own ID, the provider works the queue, and the results file is matched back row by row.*
1. Split the day's chats into batches under the size cap and send them.
2. The provider works through the queue in its own time.
3. Each answer comes back with its ID, so it is matched to its chat.

## What do you give up with a batch?

- **Time:** Results can take up to a day. Anthropic says most batches finish within an hour, but the 24 hours is the promise you plan around.
- **Streaming:** No live stream of words. Anthropic says the results arrive as one file at the end.
- **Chained steps:** Each request is handled on its own, so a later step cannot use an answer from the same batch.
- **Expiry:** A batch that runs past 24 hours expires, so plan a retry for any work it did not finish.

> **Tip:** Ask two questions before choosing: what does the team do with the answer, and by when? If the answer is needed before a meeting in an hour, a batch is the wrong tool.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: many requests sent together, answers collected later.
- [ ] The test: does a person or a live screen wait for the reply?
- [ ] The cost benefit, with the official discount named.
- [ ] The costs: up to a day, no stream, each request on its own.
- [ ] Practical care: size caps, custom IDs and retries for failed rows.
- [ ] A real example, such as a nightly tagging job at a bank's support team.

**Common traps**

- Trap: "Batch is always cheaper, so send everything through it." Better: Cheaper only helps work nobody waits on. A live screen needs a live call, whatever the price.
- Trap: "Batch results will come back in a few seconds." Better: Plan around the 24-hour deadline. Most batches finish sooner, but the deadline is the promise.
- Trap: "Just put all 300,000 requests in one batch." Better: Every batch has a size cap. Split the job, and give every request a custom ID so results match.

## Can you spot the right design?

**Spot the right design:** Your nightly job must tag 300,000 chats. Which code is the right design?

A. for chat in day_chats: tags.append(call_model(chat))  # one live call at a time
B. batch = build_requests(day_chats)  # one request per chat, each with a custom ID, split under the cap
C. reply = call_model(chat); show_agent(reply)  # each chat, the moment it arrives
D. submit_batch(all_300000_requests)  # one batch of every chat, no split

**Answer:** B. Nobody waits on the nightly tags, so a batch fits and costs about half. Splitting under the cap and giving each request a custom ID keeps every answer matched to its chat.

**Quick check:** A chat widget needs an answer in two seconds. A nightly report can take a day. Which setup is right at the lowest cost?

A. Batch both, to save money
B. Live call for the widget, batch for the nightly report
C. Live call for both
D. Batch for the widget, live call for the nightly report

**Answer:** B. A batch can take up to a day, so it cannot serve a live screen. Use a live call where a person waits, and a batch where nobody does. Live calls for both would work but cost full price for the report.

## Can you answer these from memory?

**Flash cards**

- **What is a batch API?** Many requests sent together, processed later, with the results collected at the end.
- **When do you use one?** When nobody waits on the reply, such as nightly evaluations or bulk classification.
- **How much cheaper?** Both OpenAI and Anthropic charge half the standard price for batch work.
- **How fast?** Within 24 hours at most. Anthropic says most batches finish within an hour.
- **What do you give up?** Instant replies, streaming, and any step that needs an answer from the same batch.
- **Why a custom ID?** It matches each answer back to the input it came from.

## Likely follow-up questions

- Q330 How do you handle rate limits and 429 errors? https://designervenkat.online/interview/ai/how-do-you-handle-rate-limits-and-429-errors
- Q334 How do you cut cost on a cloud-hosted LLM workload? https://designervenkat.online/interview/ai/how-do-you-cut-cost-on-a-cloud-hosted-llm-workload
- Q314 Static vs continuous batching? https://designervenkat.online/interview/ai/static-vs-continuous-batching
- Q332 Cold starts and autoscaling? https://designervenkat.online/interview/ai/cold-starts-and-autoscaling
- Q345 Design single-GPU inference batching. https://designervenkat.online/interview/ai/design-single-gpu-inference-batching

## Learn it in depth

- [Prompt Caching](https://designervenkat.online/learn/ai-engineering/prompt-caching)
- [Watching cost and speed](https://designervenkat.online/learn/ai-engineering/cost-latency-monitoring)
