Batch processing (the Batch API) hands the requests to the provider all at once, and you do not wait for the results, in exchange for a 50% discount. It is cheap because you let the provider choose when to compute, not because the model computes faster.
files + batches interface, one codebase can send batches to OpenAI, Azure, Vertex, Bedrock, Mistral, vLLM, and xAI. It does not make batch processing cheaper. Each provider sets the price.Open the pricing pages for OpenAI, Anthropic, and Gemini, and you see the same option: Batch, half price. The condition is that you do not take the results right away. You wait up to 24 hours. Same model, same output. Why half price? This essay first looks at how each provider offers it and what they charge, then explains why it is cheap, and finally how LiteLLM wires them into one codebase.
Background: during inference the GPU reads the model weights over and over. Running several requests together is the most economical. See illustrate of vLLM. A cache hit being cheap is a different mechanism. See illustrate of KV Cache and illustrate of Prefix Caching (prefix caching). This essay is about a third way to save money: trade time for money.
Look at it from the outside first. For the caller, batch processing is a "request file in, result file out" interface. There is no streaming output, and no promise of when it is done. The figure below is the official price of a few models (per million tokens, read on 2026-11-26). Claude's batch price comes from the price table in the Anthropic batch processing docs. The standard price comes from the official pricing page of 2026-11-24 (see the appendix of illustrate of KV Cache). DeepSeek has no batch processing interface. The matching price is the off-peak price on the official pricing page.
Two bars per model. Gray is the standard price. Blue is the batch price (the off-peak price for DeepSeek). Input and output each use their own scale. The right-hand column is blue ÷ gray. All 5 models are 0.5×.
The numbers are the same: input and output are both cut in half. Now look at how the rules differ:
| Vendor | Discount | Wait cap | Per-batch cap | Result retention / expiry |
|---|---|---|---|---|
| OpenAI | 50% of the standard price | 24 hours (completion_window can currently only be set to 24h) | 50,000 requests, input file 200 MB | The output file is kept for 30 days by default. Requests unfinished at the deadline are cancelled. Finished ones are billed as usual. |
| Anthropic (Message Batches) | 50% of the standard price | 24 hours. The docs say most finish within 1 hour | 100,000 requests or 256 MB, whichever comes first | Results are kept for 29 days. If it does not finish within 24 hours, it expires |
| Google Gemini | 50% of the standard price | Target 24 hours, most finish sooner. Still unfinished after 48 hours counts as expired (JOB_STATE_EXPIRED) | Inline requests < 20 MB; max file 2 GB | — |
| Amazon Bedrock | Some models are 50% below the on-demand price | Not checked this time | Not checked this time | — |
| DeepSeek | No batch processing interface. The off-peak price is half the peak price (synchronous calls) | None | — | — |
Behind this table there are really three forms, and all three sell the same thing: flexibility in time.
How long do you actually wait? The docs only give a cap. Anthropic writes "most batches finish within 1 hour." OpenRouter's own batch processing beta (not OpenAI's data; I only read the summary) says a median of 7 minutes, and 90% within 1 hour. See their blog. 24 hours is the cap, not the typical value, but you cannot ask it to go faster.
The five steps are basically the same at each provider. The figure below uses OpenAI's format (LiteLLM follows it too). Click Next step to walk through them.
Five steps: write the file, upload, create the batch, queue, download. Only step 4 requires "waiting," and while you wait you hold no connection.
Watch two details. First, the results in the output file are not guaranteed to follow the input order. You have to match them with the custom_id you wrote. Second, a single request in the batch can fail while the others finish as usual. OpenAI writes the failures into a separate error file. Anthropic marks each result as success, error, cancelled, or expired. A retry uses custom_id to pick out the failed ones and resubmit only those. You do not rerun the whole batch.
(What follows is derived from the mechanism, not from a vendor document. Vendors have not published internal costs. The official docs only give prices and rules.)
A sketch. Through the day, real-time requests (gray) swing up and down. GPU capacity (the red dashed line) is fixed. Blue is the spare capacity, which batch processing can fill. The amber vertical bands are the peak hours marked in the DeepSeek docs. The shape of the gray curve is a sketch I drew, not real traffic.
First, the cost of a GPU is fixed. The machine is bought or rented. It costs money whether requests show up or not. The denominator in the cost formula is "how many tokens this card actually computed in a day." Idling is pure waste. Fill a little more, and the cost of each token drops a little.
Second, real-time traffic swings a lot through the day. Capacity has to be sized for the peak. Below the gray in the figure above is real-time requests. Blue is the gap at the valley. DeepSeek writes the peak hours on the pricing page (UTC 01:00–04:00 and 06:00–10:00, which is 09:00–12:00 and 14:00–18:00 Beijing time, exactly working hours). Off-peak is half price. That puts "the valley is cheaper" directly on the price list. The Gemini docs explain Flex with the same line: use "opportunistic, off-peak compute."
Third, batch processing gives the provider the freedom to pick the time. A real-time request has to start emitting tokens within a few seconds. It cannot wait. A batch request can sit in a queue and run when a gap opens. The provider's gain: the valley has work too. Your cost: you do not know exactly when it will be done.
Fourth, a batch uses a GPU's compute more fully. In the Decode stage, every step has to read tens of GB of weights once. Computing several requests together costs almost no extra time (see the mechanism in illustrate of vLLM). Batch processing has no time-to-first-token requirement. The scheduler can push the concurrency of one step up to the limit. It can also group requests that share a prefix and reuse the KV Cache. Anthropic's docs suggest this: a batch may run past 5 minutes, so use it with a 1-hour cache lifetime, and the cache hit rate is higher.
Fifth, batch processing can be interrupted and retried. Gemini describes batch processing as "preemptible (sheddable), but with a 24-hour system of automatic retries and queueing." When real-time traffic arrives, the compute for batch processing can be given up first, and the work finished later.
The test: was this discount computed from a cost formula, or is it a pricing decision?
Assume 2,000 input tokens and 500 output tokens per request, and 1,000,000 requests in total. The standard price for Claude Sonnet 5.5 is $2 / $10 (per million input / output tokens). The batch price is $1 / $5.
| Input | Output | Total | |
|---|---|---|---|
| Token total | 2,000 MTok (2 billion) | 500 MTok (500 million) | — |
| Standard price | 2,000 × $2 = $4,000 | 500 × $10 = $5,000 | $9,000 |
| Batch price | 2,000 × $1 = $2,000 | 500 × $5 = $2,500 | $4,500 |
(MTok means million tokens.) 1,000,000 requests are over Anthropic's per-batch cap of 100,000, so you split them into at least 10 batches. Assumptions in this bill: the output length and the input length are both estimates. The real bill is the usage returned by the API. If a few hundred thousand requests share a long system prompt, you can also stack prompt caching. The official docs suggest a 1-hour cache. How much extra discount stacks depends on each provider's pricing page (I did not check them one by one).
LiteLLM is an open-source Python library plus a proxy server (Proxy). For batch processing, it does two things: A unified interface (you write OpenAI-format code once) and routing (it sends to different vendors according to the config). It does not make batch processing cheaper. The discount comes from the vendor.
According to the LiteLLM batch processing docs as of 2026-11-26, the providers that support batch processing are OpenAI, Azure, Vertex AI, Amazon Bedrock, Mistral, vLLM, and xAI. This list has no direct Anthropic. To use Claude batch processing, either go through Bedrock or Vertex, or call Anthropic's own SDK (software development kit).
The LiteLLM Proxy sits between your code and the providers: it checks the file, issues a managed file id, picks a deployment, and checks ownership.
Usage 1: call it directly in Python (SDK). Upload the file, then create the batch, poll, and finally download. The snippet below is the OpenAI example copied from the official docs. Match the function names.
import litellm, asyncio, os
os.environ["OPENAI_API_KEY"] = "sk-..."
async def main():
# 1. Upload mydata.jsonl (one request per line; the format is step 1 above)
f = await litellm.acreate_file(
file=open("mydata.jsonl", "rb"),
purpose="batch",
custom_llm_provider="openai",
)
# 2. Create the batch
b = await litellm.acreate_batch(
completion_window="24h",
endpoint="/v1/chat/completions",
input_file_id=f.id,
custom_llm_provider="openai",
)
# 3. Poll until a terminal state (completed / failed / expired / cancelled)
while True:
b = await litellm.aretrieve_batch(batch_id=b.id, custom_llm_provider="openai")
if b.status in ("completed", "failed", "expired", "cancelled"):
break
await asyncio.sleep(30) # Batch processing is measured in minutes. Do not poll every 5 seconds
# 4. Download the results (the output file id is on a completed batch)
out = await litellm.afile_content(file_id=b.output_file_id, custom_llm_provider="openai")
print(out.text)
asyncio.run(main())
Usage 2: start the LiteLLM Proxy, and call it with any OpenAI SDK. It fits several people and several services sharing one set of keys and limits. Minimal config (from the official docs):
model_list:
- model_name: gpt-6.1-sol
litellm_params:
model: openai/gpt-6.1-sol
api_key: os.environ/OPENAI_API_KEY
files_settings:
- custom_llm_provider: openai
api_key: os.environ/OPENAI_API_KEY
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
litellm --config config.yaml # RUNNING on http://0.0.0.0:4000
Then the client points base_url at the proxy. Everything else is exactly the same as calling OpenAI directly:
from openai import OpenAI
client = OpenAI(base_url="http://0.0.0.0:4000", api_key="sk-<your-litellm-key>")
f = client.files.create(file=open("request.jsonl", "rb"), purpose="batch")
b = client.batches.create(input_file_id=f.id, endpoint="/v1/chat/completions",
completion_window="24h")
# Then poll with client.batches.retrieve(b.id), and download with client.files.content(b.output_file_id)
Usage 3: managed files (Managed Files): one model name, several deployments, load balancing. Put the same batch model name on several deployments, and set mode: batch. On upload, pass target_model_names. The file is written to every matching deployment, and batches are load-balanced across them. From the Managed Files docs (this feature is marked BETA, the SDK does not support it, and it needs Postgres to store file ids):
model_list:
- model_name: "gpt-5.4-mini-batch"
litellm_params:
model: azure/gpt-5.4-mini-general-deployment
api_base: os.environ/AZURE_API_BASE
api_key: os.environ/AZURE_API_KEY
model_info:
mode: batch # mark this as a batch-processing model
- model_name: "gpt-5.4-mini-batch"
litellm_params:
model: openai/gpt-5.4-mini
api_key: os.environ/OPENAI_API_KEY
model_info:
mode: batch
f = client.files.create(
file=open("request.jsonl", "rb"), purpose="batch",
extra_body={"target_model_names": "gpt-5.4-mini-batch"}, # must match the model inside the jsonl
)
b = client.batches.create(input_file_id=f.id, endpoint="/v1/chat/completions",
completion_window="24h")
A few pitfalls (all from the two official docs above):
request.jsonl's model must be the model name on the proxy. In managed-file mode it must be a mode: batch model name, and it must match the target_model_names from the upload.disable_batch_input_file_rate_limiting: true.client.batches.cancel(batch.id). The status becomes cancelling, then cancelled.custom_id, output parsing, and error-file handling are all correct, then scale up.custom_id. 24 hours is the cap.