FrugentSign in ↗

Token economics

Batch processing vs caching: which lowers LLM costs?

Compare asynchronous batch processing with prompt and response caching. Match the optimization to latency needs, repeated input and data freshness.

Batch processing and caching solve different problems. Batching changes how independent requests are submitted and scheduled. Caching reuses work or results. A workload can benefit from either, both or neither, depending on its deadline and repetition.

Use batch work when waiting is acceptable

Examples include an overnight document classification job, a large offline evaluation or a scheduled content transformation. The user does not need each result before making the next decision, so the application can accept asynchronous completion.

OpenAI documents a Batch API for asynchronous groups of requests. Check its current model support, completion window, limits and pricing before planning a job. Those terms are provider-specific rather than a property of all batch systems.

Use caching when something repeats safely

Stable input may qualify for a provider’s prompt cache. A fresh request can still need a new answer, so this does not make every output reusable. Application response caching requires a separate decision about equivalence, permissions and freshness.

A hypothetical nightly job could batch 10,000 independent records while reusing stable instructions where the provider supports that combination. Do not assume two advertised discounts stack: check the applicable billing rules and confirm the observed usage.

Do not batch a live decision chain blindly

If step two depends on the result of step one, they are not independent requests ready to submit together. A browser session that reads a page and then chooses an action has a different shape from a list of offline classification tasks.

You may be able to batch independent preparation or later analysis, but preserve the dependencies of execution. Moving a user-facing confirmation into an unattended batch can change the task’s authorization model. Lower inference cost does not justify that change.

Track completion and partial failure

Assign stable identifiers to inputs and match results back to them. Do not rely on response order. Record which records completed, which failed and which need retry, using the batch provider’s documented result format.

Compare total job cost and completion time at the same quality target. Include result storage, validation and retries. If only a few records failed, a targeted retry is easier to audit than rerunning the entire job and hoping duplicates do not matter.

Build a retry list instead of rerunning everything

For a hypothetical 1,000-record job, suppose 980 records return validated results and 20 have explicit failures. Keep those outcomes by stable record ID and create a retry set from the 20 failures. If the application writes downstream records, make those writes idempotent independently of the model request. A successfully generated response is not proof that its downstream write committed, and an uncertain write should be reconciled before retry.

Sources and further reading

Keep exploring

Compare local plans · Get started

Prompt caching vs response caching: LLM cost guide

Compare prompt caching, response caching and action caching. Learn which repeated AI work each removes, when reuse is safe, and how to measure the result.

AI agent latency vs token cost: measure both

Separate inference latency, tool execution and user wait time. Learn why fewer tokens, faster responses and lower workflow costs are different outcomes.

Why your AI agent API bill keeps growing

Understand repeated context, output, retries and tool charges in an AI agent bill. Build a task-level cost record before choosing an optimization.