Topic 3 of 5 · 4 min read
Moving non-urgent calls to discounted batch pricing
Goal: Identify which calls in a feature can tolerate batch latency and estimate the saving from the batch discount.
Batch processing runs your requests asynchronously, usually within a day, for about half the normal price, so send it every call that nobody is waiting for.
Check yourself · 1 of 3
Which task suits a batch API best?
Why it matters
Not every model call has a user watching a spinner. Classifying last month's tickets, summarising documents overnight, scoring a backlog of evaluations and generating product descriptions can all wait. Claude's pricing page lists batch tokens at 50 % of standard rates, and OpenAI offers a similar batch discount. For a workload that is mostly offline, that halves the bill with no change in quality.
How it works
You upload a file or list of requests, each with its own id. The provider processes them when capacity allows and returns the results, normally within 24 hours, often sooner. You poll for completion and match answers to requests by id. Results can arrive in a different order than you sent them.
How to do it
- List the calls in a feature and write the deadline for each. "User is waiting" means live. "Needed by tomorrow morning" means batch.
- Split by latency, not by feature. One feature may have a live path for a single document and a batch path for the nightly backfill.
- Estimate the saving: batch-eligible spend multiplied by the discount. Only that part of the bill is cut.
- Design for partial failure: individual requests in a batch can fail or expire. Retry only those ids.
- Combine with caching: batches can take longer than the 5-minute cache, so use the longer cache duration where the provider offers it.
Before and after
Weak: "Our whole summariser is on the live API because it started as a chat feature." The nightly job summarising 40,000 archived documents pays full price.
Fixed: the live path stays as it is, and the nightly job goes through the batch API. If that job was 60 % of spend, the bill drops by about 30 %.
What goes wrong
- Batching a request a user is waiting for, then discovering it can take hours.
- Treating the discount as applying to the whole bill instead of only the batched share.
- Assuming results come back in the order sent.
- Not handling expired or errored requests, so some rows silently stay empty.
Examples
Sorting a feature's calls by deadline
| Call | Daily spend | Deadline | Route |
|---|---|---|---|
| Chat reply | $120 | seconds | Live |
| Nightly ticket tagging | $90 | by 8 am | Batch |
| Weekly report summaries | $40 | by Monday | Batch |
| Moderation on upload | $30 | seconds | Live |
Batch-eligible spend is $130. At a 50 % discount the saving is $65 a day, or about 26 % of the $280 total.
Submitting and collecting a batch
const batch = await client.messages.batches.create({
requests: tickets.map((t) => ({
custom_id: `ticket-${t.id}`,
params: { model, max_tokens: 100, messages: [{ role: "user", content: t.text }] },
})),
});
// later: poll until processing_status is "ended", then read results by custom_id
The custom_id is how you match each answer to its ticket.
Key points
- Batch APIs process requests asynchronously, usually within 24 hours, at a discount of about half on Claude.
- Only calls where nobody is waiting for the answer belong in a batch.
- The saving applies only to the batched share of spend, not to the whole bill.
- Each batched request carries an id, because results are matched by id and may not return in order.
- Failed or expired requests inside a batch need their own retry.
Common mistakes
- Sending a user-facing request through the batch route because it is cheaper.
- Applying the discount to the whole bill when only part of it can be batched.
- Relying on result order instead of the request id.
- Ignoring errored and expired requests in the finished batch.
Check yourself · 2 of 3
A feature spends $200 a day, of which $80 is on calls that can be batched at a 50 % discount. How much does batching save per day?
Check yourself · 3 of 3
A finished batch returns results in a different order than the requests were sent. How should you match answers to inputs?
Practice items, not counted towards your mastery.
Start here
- Claude API pricing (opens in a new tab)DocsFree
Per-million-token prices, the cache write and read multipliers and the batch discount in one table.
- Prompt caching (Claude docs) (opens in a new tab)DocsFree
Cache breakpoints, the 5-minute and 1-hour lifetimes and the usage fields that report writes and reads.
- Batch processing (Claude) (opens in a new tab)DocsFree
How the Message Batches API works and what it costs compared with standard calls.
More for this topic
- Batch API (OpenAI) (opens in a new tab)DocsFree
Asynchronous batch jobs on OpenAI for work that can wait.