arrow_backGuides / Cutting LLM Costs
Updated July 2026 12 min read Advanced

Cutting LLM Costs
without compromising quality

The AI bill climbs fast. The good news: most of the cost is unnecessary. With proper prompt caching you save up to 90% on repeated tokens, with batch you save 50% on non-urgent work, and the right model choice cuts more. In this guide: how each technique works, and how not to break the cache by accident.

~90%
saved with caching
50%
Batch discount
x5–x25
gap between models

Where the cost actually comes from

LLM billing is by tokens — units of text. You pay separately for input (what you send the model: prompt, context, documents) and for output (what the model generates), and output is always far more expensive than input. Three facts that explain why the bill balloons:

Each of these problems has a direct fix. We will go through them in order of impact.

Prompt Caching — the highest-impact technique

This is the biggest saving, and most people do not use it. Prompt caching lets the AI provider "remember" a fixed part of the prompt between requests. Instead of re-processing the 2,000 tokens of the system prompt and documents every time, the model loads them from the cache — at a dramatically reduced price (a token read from cache costs about a tenth of a regular input token).

The mechanism is based on prefix matching: the provider recognizes that the start of the prompt is identical to a previous request and loads it from cache. The processing order is fixed — first the tool definitions, then the system prompt, then the messages. Therefore:

bolt
The key rule: fixed first, variable after

Put the fixed content (system prompt, tool list, background documents) at thestart of the prompt, and the variable content (the user’s question, a timestamp, a request ID) at theend. That way the fixed prefix stays cached and the changing part does not break it.

Practical key points: there is a minimum number of tokens for a cache to activate at all (around 1,024 tokens — shorter than that simply will not cache), the cache has a short lifetime (it resets after a few minutes of no use, unless refreshed), and the number of cache "breakpoints" per request is limited. The real saving comes when the same large prefix recurs across many requests — for example a chatbot with a long system prompt, or RAG with the same context documents.

How not to break the cache by accident

This is where most people fail: the cache works by an exact match of the prefix. Any change of a single byte at the start disqualifies everything after it. These are the cache’s "silent killers":

verified
How to verify the cache works

Do not guess — measure. The API response has a field reporting how many tokens were read from cache (e.g. cache_read_input_tokens). If it is zero across repeated requests, a silent killer is at work. An observability tool will show you this immediately.

Batch Processing — 50% off non-urgent work

Not every request needs an immediate answer. If you process 10,000 documents overnight, classify a dataset, or generate product descriptions — that is asynchronous work. Most providers offer a Batch API that processes such requests within a time window (usually up to 24 hours) for a 50% discount off the regular price.

The rule is simple: anything that does not need an answer within a second — into a batch. A user waiting on a chat needs real time; an overnight report run does not. Half the bill on all that work simply disappears.

Model choice & context

The most expensive mistake is using the strongest model for everything. The gap between a flagship model and a small one is 5× to 25× in price. The vast majority of tasks — classification, extraction, short summarization, routing — do not need the strongest model.

The savings checklist

check_circle Enable prompt caching on the fixed prefix — the single step with the biggest return.
check_circle Verify that acache hit actually happens — check the cache-read field in the response.
check_circle Move all non-urgent work to theBatch API (half price).
check_circle Route models — do not use a flagship model for a task a small one solves.
check_circle Trim context and cap output length — fewer tokens on every request.
warning
Do not waste optimization on what is not measured

Before you optimize — measure. Without cost tracking you are guessing. Connect observability, find which feature or model eats the budget, and optimize that. 20% of the code is usually responsible for 80% of the cost.