Request Batching
Price break for waiting
Many providers discount batched (async) requests: you submit a batch endpoint and pay less for latency-flexible work. Batching also cuts your own fan-out: aggregate independent calls into one pipeline with fewer round trips and better GPU utilization when you control inference.
What you will learn
- Understand where batch APIs discount cost
- Identify latency-flexible workloads
- Aggregate independent calls into batches
What is this?
Request batching groups independent LLM calls: provider batch APIs process them asynchronously at a lower per-token rate (targeting 24h/flexible SLAs), and your own servers can collect many small jobs into fewer, bigger requests. It trades latency for price — right for offline and deferred work, wrong for interactive chat.
Why do you need it?
- A summary job over 10,000 documents at interactive prices is needlessly expensive.
- Providers discount batch to move load to low-demand windows.
- Fewer, larger requests amortize overheads (auth, queueing, network) too.
Mental model
Batching
Shipping by container
You could courier every parcel same-day (each costly), or wait a few hours and send a container at a volume rate. Same items, way lower bill.
How it works
- Write deferred tasks (summary, extraction, backfill) to a job queue.
- Submit them to the provider's batch endpoint (or your own batcher with FIFO windows).
- Poll for results; retry failed items; attribute cost per job.
- Reserve interactive pricing only for requests where latency is visible.
Batch pipeline.
In production
- A nightly content-enrichment job runs 50,000 summaries via the batch API.
- A migration backfills embeddings in batches with a few-day SLA.
- An internal Q&A index refreshes its digest jobs overnight at the discount rate.
Best practices
- Separate interactive and batch traffic at the gateway so the right pricing applies.
- Give each submission a batch id and each item its own id for result matching.
- Set up retry and dead-letter handling per item, not per batch.
- Track batch cost vs saved dollars explicitly to justify the latency trade.
Common mistakes
- Batching latency-sensitive requests to save cents — users feel every minute.
- No per-item result matching, so a partial failure poisons the whole run.
- Forgetting that batch SLAs expire; plan result collection well inside the window.
Debugging tips
- Batch results missing → poll by batch id and item id; treat expiry as a failure case.
- Discount not materializing → confirm you're on the batch endpoint, not the sync one with quotas.
- Unusable results → check the model's max_tokens and per-item params were set per job.
Interview checkpoint
Quick quiz
Provider batch APIs are ideal for?
Batching always costs less than interactive calls for the same work.