
LLM Cost Optimization (2026): Prompt Caching, Batching, and Model Routing, with Real Numbers
LLM bills grow quietly. A prototype costs a few dollars a day, then the feature ships, traffic grows, someone adds a longer system prompt, and the monthly invoice has four digits. Most of that money is wasted on tokens that did not need to be sent, generated, or sent to an expensive model.
The good news is that the biggest savings are mechanical. Prompt caching, batch processing, shorter outputs, and routing easy requests to cheaper models can each cut costs by large factors without touching quality. You do not need a new architecture. You need to know where the tokens go and which lever fits each part of your workload.
This guide explains each lever with real prices and a worked example. A support assistant on a mid-tier model goes from $4,200 to about $711 a month, step by step, and every step is shown. It also covers what to avoid, including a semantic caching shortcut that I tested and found risky.
Many people never see a per-token bill, though. They pay a flat monthly subscription, such as Claude Pro or Max, and use the apps or Claude Code. Tokens still matter for them, because every token counts against their usage limits. Section 13 maps each lever to subscription plans, and section 14 looks at caveman, a popular tool that automates several of these savings.
The cost figures come from the same pricing engine as my LLM API cost calculator. Its prices were checked against each vendor’s pricing page on November 20, 2026. I re-checked the Claude prices used in the examples on November 30, 2026, and they had not changed. I re-checked the Gemini 4 prices on December 1, 2026, the day Google’s announced increase took effect. The caching and routing helpers in this article passed 12 tests, and the semantic caching experiment ran on a local embedding model.
This article belongs to my AI series. It pairs with my Claude, OpenAI, and Gemini API comparison, which documents each vendor’s caching rules, and my evals guide, because you cannot cut costs safely without measuring quality.
Table of Contents
- The Short Answer
- Where the Money Goes
- Measure Before You Optimize
- The Worked Example
- Prompt Caching
- Shorter Outputs
- Batch Processing
- Model Routing
- Response Caching, and Why Semantic Caching Is Risky
- Trimming Input
- Prices Change, So Watch Them
- Budgets and Guardrails
- If You Pay by Subscription
- Tools That Automate This: Caveman
- Common Mistakes
- Frequently Asked Questions
- Conclusion
- References
1. The Short Answer
| Lever | Typical saving | Best for | Risk to quality |
|---|---|---|---|
| Prompt caching | Half the bill in my example | Long, repeated prefixes such as system prompts and tools | None |
| Batch processing | 50% on both input and output | Work that can wait hours | None |
| Shorter outputs | Proportional to output tokens saved | Chatty answers and unbounded reasoning | Low, if tested |
| Model routing | Large; the cheapest tier can be 20x cheaper | Workloads with many easy requests | Medium, needs evals |
| Exact response cache | 100% of each repeated request | Identical, repeated questions | None |
| Semantic cache | Varies | Rarely worth it | High |
Apply them in this order: measure, cache prompts, batch what can wait, trim outputs, then route with evals in place. The first three are nearly free of risk, and routing is where most of the remaining money is.
If you pay a flat subscription instead of per token, the same levers stretch your usage limits instead of cutting a bill. Section 13 shows how each one translates.
Your first afternoon
- Log usage on every call, including cache reads and cache writes, grouped by feature.
- Move the stable prefix to the front of every prompt, and turn on prompt caching.
- Set a maximum output length on every call, and ask for concise answers.
- List the jobs that can wait, such as reports, backfills, and evals, and move them to the batch API.
- Build a small eval set before you route any traffic to a cheaper model.
2. Where the Money Goes
LLM APIs charge per token, with separate prices for input and output. Output costs more, often five times the input price or more for current models. For Claude Sonnet 5.5, the list price is $2 per million input tokens and $10 per million output tokens.
The tokens hide in several places.
- The system prompt and tool definitions, sent again with every request. A detailed system prompt plus a dozen tools can easily reach several thousand tokens.
- Conversation history, which grows with every turn in a chat.
- Retrieved documents in RAG systems.
- Output, including reasoning or thinking tokens, which are generally billed as output.
- Retries and loops, where a failed call or an agent step repeats everything.
In most production apps, the stable prefix dominates input. That is exactly what prompt caching targets.
3. Measure Before You Optimize
Every API response reports token usage. Log it for every request, with enough context to group it later.
- Per feature: Which product feature made the call?
- Per model: Which model and settings were used?
- Input breakdown: Total input, cached reads, and cache writes.
- Output: Including reasoning tokens where the API reports them separately.
- Outcome: Did the request succeed, and did the user accept the answer?
The field names differ by vendor. Claude reports input_tokens, cache_creation_input_tokens, cache_read_input_tokens, and output_tokens in each response’s usage object. My API comparison lists the equivalent fields for OpenAI and Gemini.
Two derived numbers deserve their own place on your dashboard.
- Cache read share: Cache reads divided by all input tokens. If it drops suddenly, something in your prefix started changing between requests.
- Escalation rate: For cascades, the share of requests the cheap model could not handle. If it rises, the cheap model is failing more often, and your savings are shrinking.
Cost per successful task
The number that matters is not cost per request. It is cost per successful task. A cheap model that fails half the time and triggers a retry on an expensive model can cost more than using the expensive model directly. You can only compute success with an evaluation set, which is why cost work and eval work belong together.
4. The Worked Example
The workload
A customer support assistant handles 200,000 requests a month. Each request sends 8,000 input tokens: a 6,000-token stable prefix with the system prompt, tool definitions, and policy text, plus 2,000 tokens of conversation and user message. It returns 500 output tokens on average. It runs on Claude Sonnet 5.5.
Step by step
| Step | Monthly cost | Saving vs baseline |
|---|---|---|
| 0. Baseline: Sonnet 5.5, no caching | $4,200.00 | 0% |
| 1. Add prompt caching for the 6,000-token prefix | $2,044.42 | 51% |
| 2. Cut average output from 500 to 300 tokens | $1,644.42 | 61% |
| 3. Route 60% of requests to Haiku 5.5, if evals confirm quality | $710.54 | 83% |
| For reference: every request on Haiku 5.5 | $87.96 | 98% |
I computed every row with the cost engine behind my calculator, using Claude’s list prices: Sonnet 5.5 at $2 input and $10 output, and Haiku 5.5 at $0.10 input and $0.50 output, per million tokens.
One caveat applies to Haiku 5.5. Those prices hold for prompts up to 100,000 tokens. Above that, Haiku 5.5 costs $0.50 input and $2.50 output per million, five times more. The worked example stays far below the limit, but long-document workloads do not.
How the caching row was computed
Caching is not free. The first request after the cache expires writes the prefix at a higher price. Claude’s default cache lives for five minutes, and a read refreshes it. I assumed the prefix is rewritten once every five minutes around the clock, which is 8,640 writes a month.
- Cache writes: 8,640 writes of 6,000 tokens is about 3.2% of all input tokens, billed at $2.50 per million.
- Cache reads: The rest of the prefix, about 71.8% of input, is billed at $0.10 per million.
- Uncached input: The remaining 25%, the conversation itself, is billed at the normal $2 per million.
That turns $3,200 of monthly input into about $1,044. Output is untouched by caching, so it stays at $1,000.
This is a deliberately conservative assumption. Every cache read refreshes the timer, so steady traffic keeps the cache warm, and the prefix is rewritten far less often. Real writes happen mainly after quiet periods, such as nights, and after you deploy a changed prompt. Here is how the result moves with the write rate.
| Prefix rewritten | Cache writes | Monthly cost with caching |
|---|---|---|
| Every 5 minutes, all month | 3.24% of input | $2,044.42 |
| Once an hour | 0.27% of input | $1,930.37 |
| About ten times a day | 0.11% of input | $1,924.32 |
The write rate matters less than you might expect. The big saving comes from the reads, so even the pessimistic case keeps most of it.
Reading the table honestly
Steps 1 and 2 are pricing facts. Step 3 is not. The $711 figure assumes that Haiku handles 60% of requests well enough, which is a quality claim that only your evals can confirm. Treat it as “about $711 if the cheap model succeeds on 60% of traffic.”
The result is sensitive to that assumption. Section 8 shows a cascade that sends failures to the stronger model, and its table shows what each task costs at a 90% and a 70% success rate on the cheap model. Read that table before you plan a budget around step 3.
5. Prompt Caching
How it works
The model processes your prompt from the beginning. When a request starts with exactly the same tokens as a recent request, the provider can reuse that earlier work. You pay a fraction of the normal input price for the reused part, and the response often starts faster too.
Claude’s prices for Sonnet 5.5
| Token type | Price per million | Relative to input |
|---|---|---|
| Normal input | $2.00 | 1x |
| Cache write, 5-minute TTL | $2.50 | 1.25x |
| Cache write, 1-hour TTL | $4.00 | 2x |
| Cache read or refresh | $0.10 | 0.05x |
| Output | $10.00 | 5x |
OpenAI and Google also discount cached input heavily, with different rules for how caching starts, minimum prefix lengths, and write prices. My API comparison has a side-by-side table.
Rules that make caching work
- Put stable content first. System prompt, then tool definitions, then reference documents, then conversation, then the new message. The cache only covers an exact prefix, as this layout shows.
| system prompt | tool definitions | reference docs | conversation | new message |
|<------------ identical on every request: cached ------------>|<- changes: billed normally ->|
- Keep volatile content out of the prefix. A timestamp, a user name, or a random ID near the top breaks the cache for everything after it.
- Keep tool order stable. Sorting tools the same way every time avoids accidental cache misses.
- Check the minimum length. Very short prefixes are not cached. The minimum varies by model and vendor.
- Pick the TTL by traffic. With steady traffic, the 5-minute cache stays warm on its own. With bursty traffic and long gaps, a 1-hour cache may save more, despite its higher write price.
- Verify hits in the usage data. Do not assume caching works. Read the cached token counts on real responses.
When caching does not help
Caching saves nothing when every request is different from the first token, or when traffic is so sparse that the cache always expires before the next request. In that second case, each request pays the write premium and gets no reads, so caching can even cost slightly more.
6. Shorter Outputs
Output tokens are the most expensive tokens, and models often produce more than you need.
- Ask for brevity explicitly, with a target such as “answer in at most three sentences.”
- Set a maximum output length on every call, as a safety net against runaway answers.
- Use structured output for machine-readable results. A JSON object with three fields is far shorter than prose.
- Control the reasoning effort. Thinking tokens are generally billed as output. Current models from all three vendors let you set an effort or reasoning level. Test a lower level on your eval set before you settle on the default.
- Do not ask the model to repeat the input. Instructions like “first restate the question” cost money and rarely help.
In the worked example, cutting the average answer from 500 to 300 tokens saved $400 a month on its own. Check with your evals that shorter answers still solve the user’s problem.
Coding agents are different
Output matters most in chat-style apps, where answers are long and prompts are short. Coding agents turn that around. Every turn re-sends the conversation, file contents, and tool results, so input dominates the bill. One outside test reported by the caveman project found that output was only 0.3% of all tokens across 662 Claude Code sessions. For agents, trimming what the model reads, covered in section 10, usually saves far more than trimming what it writes.
7. Batch Processing
All three major vendors offer batch processing at half the normal price. You submit many requests at once, and the results arrive asynchronously. For Claude, the discount is 50% on both input and output. Its documentation says most batches finish within an hour, and a batch that is not finished within 24 hours expires.
Good fits for batch
- Nightly or weekly reports, such as summarizing the day’s support tickets.
- Backfills, such as tagging or classifying a large archive.
- Evaluations, which often run hundreds of prompts at once.
- Content generation that is reviewed before publishing.
An example
A nightly job summarizes 60,000 tickets a month, each with 3,000 input tokens and 400 output tokens, on Sonnet 5.5. Run live, it costs $600 a month. Run through the batch API, it costs $300. The work and the output are identical.
Batch and caching can work together, since cached prefixes are also discounted within batches. The exact rules differ by vendor, so check the documentation for your provider.
8. Model Routing
Model prices span a huge range. On Claude’s price list, Haiku 5.5 costs $0.10 per million input tokens, and Sonnet 5.5 costs $2.00, which is 20 times more. Many requests, such as classifying a ticket, extracting a date, or answering a common question, do not need the stronger model.
Three ways to route
- Rules: Route by task type. Classification and extraction go to the cheap model. Open-ended reasoning goes to the strong one. This is simple and predictable.
- A classifier: A small model or a set of heuristics decides which tier each request needs.
- A cascade: Try the cheap model first. If a check fails, send the request to the strong model.
A tested cascade
The cascade below escalates when your own deterministic check fails, such as invalid JSON, a missing field, or a failed validation.
// Cascade: try the cheap model, escalate when a deterministic check fails.
// callCheap / callStrong return { text, costUsd }. accept(text) is your own validator.
export async function cascade(request, { callCheap, callStrong, accept }) {
const first = await callCheap(request);
if (accept(first.text))
return { ...first, model: "cheap", totalCostUsd: first.costUsd };
const second = await callStrong(request);
return {
...second,
model: "strong",
escalated: true,
totalCostUsd: first.costUsd + second.costUsd,
};
}
I tested it with fake model functions and a JSON validator. A valid cheap answer was accepted and cost only the cheap call. An answer that was prose instead of JSON escalated to the strong model, and the total cost correctly included both calls.
What escalation costs
With the cached prompt from the worked example and 300-token answers, one request costs about $0.0082 on Sonnet 5.5 and about $0.0004 on Haiku 5.5. A cascade that always tries Haiku first and escalates on failure costs this much per task.
| Haiku pass rate | Expected cost per task | Sonnet only |
|---|---|---|
| 90% | about $0.0013 | $0.0082 |
| 70% | about $0.0029 | $0.0082 |
Even when the cheap model fails 30% of the time, the cascade costs about a third of using Sonnet for everything. The catch is the check. A cascade only works when you can detect a bad answer automatically. For free-form answers without a reliable check, route by task type instead, and confirm quality with evals.
Routing needs evals
Never switch traffic to a cheaper model because a few manual tries looked fine. Run your eval set on both models, compare them case by case, and route only the task types where the cheap model holds up. My evals guide explains how to set that up.
9. Response Caching, and Why Semantic Caching Is Risky
Exact-match caching is safe
If many users send the identical request, store the answer and return it without calling the model. The cache key must include everything that changes the answer: the model, the system prompt, the settings, and the full prompt.
// Exact-match cache. Safe because only identical requests share an answer.
export class ResponseCache {
constructor({
ttlMs = 60 * 60 * 1000,
maxEntries = 10_000,
now = () => Date.now(),
} = {}) {
this.ttlMs = ttlMs;
this.maxEntries = maxEntries;
this.now = now;
this.map = new Map();
this.hits = 0;
this.misses = 0;
}
// The key covers everything that changes the answer: model, settings, and the full prompt.
static key({ model, system = "", prompt, temperature = 0 }) {
const normalized = prompt.trim().replace(/\s+/g, " ").toLowerCase();
return JSON.stringify([model, system, temperature, normalized]);
}
get(req) {
const k = ResponseCache.key(req);
const e = this.map.get(k);
if (e && this.now() - e.at < this.ttlMs) {
this.hits++;
return e.value;
}
if (e) this.map.delete(k);
this.misses++;
return undefined;
}
set(req, value) {
if (this.map.size >= this.maxEntries)
this.map.delete(this.map.keys().next().value); // drop the oldest
this.map.set(ResponseCache.key(req), { value, at: this.now() });
}
}
My tests confirmed the important behaviors. Identical questions hit the cache, even with different capitalization and spacing. A different model, a different system prompt, or a reworded question missed it. Entries expired after their time limit, and the oldest entry was dropped when the cache was full.
Two cautions apply to this cache. Lowercasing the prompt is a choice, and you should drop it if case can change the meaning in your domain. Never share cached answers between users when the answer depends on private data, such as “what is my balance?”
Semantic caching sounds great but is risky
Semantic caching goes further. It embeds each question and reuses a cached answer when a new question is similar enough. The idea is that “When are you open?” can reuse the answer to “What are your opening hours?”
I tested whether a similarity threshold can separate questions that mean the same thing from questions that only look alike. I embedded ten pairs with EmbeddingGemma, running locally, and measured cosine similarity.
| Pair | Same meaning? | Similarity |
|---|---|---|
| “What are your opening hours?” / “When are you open?” | Yes | 0.914 |
| “How do I reset my password?” / “I forgot my password, how can I change it?” | Yes | 0.885 |
| “Do you ship to Canada?” / “Can I order from Canada?” | Yes | 0.845 |
| “Where is my package?” / “Can you track my order for me?” | Yes | 0.679 |
| “Cancel my subscription” / “How do I stop my plan from renewing?” | Yes | 0.655 |
| “How do I reset my password?” / “How do I reset my two-factor authentication?” | No | 0.708 |
| “Is shipping free to Germany?” / “Is shipping free to Greece?” | No | 0.688 |
| “What is the price of the Pro plan?” / “What is the price of the Team plan?” | No | 0.615 |
| “Delete my account” / “Delete my last message” | No | 0.537 |
| “Can I get a refund for my order?” / “Can I get an invoice for my order?” | No | 0.533 |
The two groups overlap. The different-meaning pair about passwords and two-factor authentication scored 0.708, higher than two genuine paraphrases. No single threshold works. A threshold low enough to catch “Cancel my subscription” would also serve the password answer to someone asking about two-factor authentication.
A high threshold of 0.8 avoided every wrong answer in this small sample, but it served only three of the five paraphrases from cache. Ten pairs prove nothing about your data, so test your own question pairs before you trust a threshold. My conclusion is that semantic caching is rarely worth the risk for answers that matter. Use exact-match caching, and send near-duplicates to a cheap model instead.
10. Trimming Input
- Retrieve instead of stuffing. Sending a whole manual with every question is expensive. Retrieval sends only the relevant passages, as my RAG guide shows. For small, stable documents, caching the full text can be the cheaper option, so compare both.
- Summarize long conversations regularly. After a set number of turns, replace older messages with a short summary.
- Prune the tool definitions. Only send the tools a request might need. Long tool descriptions and schemas are input tokens on every call.
- Shorten the system prompt. Remove rules the model already follows, and duplicated instructions. Test with your evals before and after.
- Count tokens with each vendor’s tools. Tokenizers differ, so the same text costs a different number of tokens on different models.
- Shrink tool output in agents. Logs, test runs, and search results are often thousands of lines, and agents re-send them on later turns. Ask for filtered output, such as only failing tests, or use a tool that trims it, as section 14 describes.
11. Prices Change, So Watch Them
Model prices move, and not always down. On December 1, 2026, Google doubled the price of Gemini 4 Carbon and Gemini 4 Argon, from $2 input and $10 output per million tokens to $4 and $20, as it had announced weeks earlier. For the worked example’s workload without caching, Carbon went from $4,200 to $8,400 a month overnight. Gemini 3.8 Flash is next, with an increase listed for January 1, 2027.
- Track announced price changes for every model you use.
- Check your actual price, not just the list price. Prices can differ by region and by access route. For example, Claude lists a 1.1x multiplier for US-only inference on current models, and cloud marketplaces and third-party gateways set their own prices.
- Compare cost per task, not price per token, because tokenizers and output lengths differ between models.
- Keep model choice configurable, so you can switch when prices or quality change.
- Re-run evals before switching, since a cheaper model is only cheaper if it still does the job.
You can model these scenarios yourself in my LLM API cost calculator. It includes caching, batch, long-prompt pricing, and announced price changes.
12. Budgets and Guardrails
Optimization lowers the typical bill. Guardrails stop the unusual one.
- Set a maximum output length on every call. It caps the worst case per request.
- Budget tokens per user and per day. A single user, script, or stolen key should not be able to run up a large bill. My prompt injection guide includes a tested
TokenBudgetclass. It reserves the worst case before each call and refunds what was not used.
const budget = new TokenBudget(200_000); // tokens per user per day
if (!budget.charge(userId, inputTokens, maxOutputTokens))
throw new Error("daily budget reached");
const reply = await callModel(request);
budget.refund(userId, maxOutputTokens - reply.usage.output_tokens);
- Cap every agent loop. Limit steps and time per task, because a looping agent multiplies cost with every turn.
- Alert on spending anomalies. Compare daily spend with the recent average, and alert on sharp jumps.
- Set spending limits in the vendor console, as a last line of defense.
13. If You Pay by Subscription
Most of this article assumes per-token API billing. Many people pay a flat monthly fee instead, for example with Claude Pro, Max, or Ultra, and use the Claude apps or Claude Code. There is no token bill, but tokens are still the currency.
How subscription limits work
According to Anthropic’s help center, paid plans have a usage limit that resets every five hours and a weekly limit. Max and Ultra plans also have a separate weekly limit for Fable, and verified Ultra accounts have no five-hour limit. Claude, Claude Code, and Claude Desktop all draw from the same limits.
Anthropic lists what uses them up faster:
- Message length and file attachments
- Conversation length, because each new message includes what came before
- Tool use and multi-step tasks, such as web search, running code, and creating files
- Model choice and effort level
When you hit a limit, you wait for the reset, upgrade your plan, or turn on usage credits. Usage credits switch you to pay-as-you-go pricing, so careless usage can become a real bill after all.
The same levers, measured in limits
| API lever | Subscription equivalent |
|---|---|
| Measure first | Watch the session and weekly bars in Settings > Usage as you change habits |
| Prompt caching | Put reused documents in a project, which Anthropic says counts less against your limits when reused, and keep working while the cache is warm |
| Trimming input | Start fresh conversations for new topics, use /clear between tasks in Claude Code, keep CLAUDE.md lean, and connect only the MCP servers you use |
| Model routing | Use a lighter model and a lower effort level for routine work, and save the top model for hard problems |
| Shorter outputs | Ask for concise answers, but expect a small effect in coding agents, as section 6 explains |
| Batch processing | No direct equivalent. The closest habit is grouping related questions into one message, which Anthropic recommends |
What subscribers cannot measure
Anthropic does not publish how many tokens one percent of a usage bar represents, and the limits can change. You cannot compute savings in dollars the way API users can. Compare habits by watching how fast the bars move on similar work, before and after a change.
Caches also expire after a while. Anthropic’s guidance says that if you return to a project after a long break, your first message counts the cached content in full again. Long, idle gaps between messages in a big conversation cost more than steady work.
Other vendors’ subscriptions, such as ChatGPT and Gemini plans, also limit usage, with their own rules. The principles carry over, but check each vendor’s help pages for the details.
14. Tools That Automate This: Caveman
Several open source tools apply these levers for you. The most popular is caveman, which started as a Claude Code skill that makes the model answer in a terse “caveman” style. When I checked on December 1, 2026, the latest release was version 5.1.0 from November 30, 2026, under the Apache 2.0 license. It has grown into a suite that works with many coding agents, using API keys or subscription logins such as Claude Pro and Max.
What it includes
- Say less: The original skill. The model answers in short, structured sentences, while code and commands stay exact.
- Read less: A local proxy that sits between your agent and the model provider. It trims logs, test output, search results, and old tool results before the model reads them, and stores every original on your disk so nothing is lost.
- Auto: Picks the model and effort level per request, lowering effort on easy asks.
- Smaller tools: Including a command that compresses memory files such as CLAUDE.md, a compressed web page reader, and keeping the prompt cache warm while you pause.
What the numbers say
The project publishes an unusually honest page of its own results, and it changes how to read the hype.
- The famous part saves the least. On the project’s own test,
/cavemancut output only 3% more than a plain “Answer concisely.” instruction, and its strongest mode,/ultracave, cut 35% more. That was ten questions, one run. The rules also add about 1,160 input tokens. - Output savings often vanish in the total. In an outside test listed on the same page, billed output fell 44% while total cost rose 0.06%. Another found that output was only 0.3% of all tokens across 662 Claude Code sessions.
- The proxy targets what actually costs money. On the project’s own 32-task benchmark with Claude Sonnet 5.5, whole Claude Code sessions cost 42.9% less, input tokens fell 16.3%, and all 32 tasks still passed. The mechanism matches section 5: fresh tool output is billed as a cache write at 1.25 times the input price, so trimming it saves more than the raw token count suggests.
Read those benchmark figures as the project’s own claims. They come from one run per task, at API prices, on tasks the project chose. I have not tested caveman myself. Its own advice is the right one: run the same work with and without it, compare your bill or your usage bars, and turn it off if it costs more.
Cautions before you install it
- The proxy sees everything. It handles every prompt, file, and credential your agent sends. Treat it like any dependency with that level of access.
- Telemetry is on by default. According to its README, the command-line tool sends usage statistics, including token counts, a random install ID, your operating system, and your IP address. Run
caveman telemetry offto stop it. - It changes very fast. Versions 5.0.0 and 5.1.0 shipped one day apart. Pin a version and read the release notes before upgrading.
- Per-request billing gains nothing from shorter answers. The project notes this for GitHub Copilot’s premium requests, because a shorter answer is still one request.
If you only want shorter answers, a single line such as “Answer concisely” in your instructions gets you most of the way. The proxy is the part worth an experiment, especially for agent sessions with lots of logs and tool output.
15. Common Mistakes
- Optimizing without measuring first. Log token usage per feature first, or you will optimize the wrong thing.
- Putting a timestamp at the top of the system prompt. It breaks the prompt cache on every request.
- Assuming that caching works. Check the cached token counts in the usage data.
- Running batch-friendly jobs live. Nightly reports and evals do not need instant answers.
- Leaving the output unbounded. Set a maximum length and ask for concise answers.
- Switching to a cheaper model without evals. Cheap and wrong is not a saving.
- Comparing price per token across vendors. Compare cost per successful task.
- Trusting semantic caching blindly. In my test, unrelated questions scored as similar as real paraphrases.
- Caching personalized answers across users. That is a data leak, not a cost saving.
- Ignoring announced price changes. A model can double in price overnight.
16. Frequently Asked Questions
I pay for a subscription. Does any of this matter to me?
Yes, it does matter. You do not pay per token, but tokens use up your five-hour and weekly limits. Shorter conversations, a lean context, and the right model for each task let the same plan do more work before you hit a limit. Section 13 maps every lever.
Which lever should I try first?
Start with prompt caching. It needs no quality trade-off, often halves the bill for apps with long system prompts, and usually takes an afternoon to set up. Then move batch-friendly work to the batch API.
Does prompt caching change the model’s answers?
No, it does not. Caching reuses the processing of an identical prefix. The model still generates a fresh answer for each request.
Is it worth self-hosting an open model to save money?
Sometimes, at high and steady volume, or when data must stay in-house. Include the cost of hardware, power, operations, and lower quality on harder tasks. My local LLM guide covers what consumer hardware can run.
How do I know a cheaper model is good enough?
Run your eval set on both models, compare them case by case, and look at the failures. If the cheap model only fails on certain task types, route those types to the stronger model.
Should I count reasoning tokens?
Yes, you should count them. Reasoning tokens are generally billed as output, at the higher rate. Higher effort settings produce more of them, so set the effort level explicitly and test it.
What is a realistic total saving?
It depends on the workload. In my example, caching, shorter answers, and routing cut the bill by 83%. Apps with short prompts save less, because there is little to cache.
Take a different app with 200,000 requests a month, 600 input tokens, no reusable prefix, and 300 output tokens. On Sonnet 5.5 it costs $840 a month, and caching changes almost nothing. Routing 60% of requests to Haiku 5.5 brings it to $361.20, a 57% saving, and that saving depends entirely on the cheap model being good enough.
17. Conclusion
Most LLM spending is avoidable. The stable prefix you send with every request can be cached for a fraction of the price. Work that can wait can run in batch at half price. Answers can be shorter, and easy requests can go to a model that costs a twentieth as much.
The order of the steps matters. Measure first, then apply the levers that carry no quality risk, which are caching, batch, and output limits. Use routing only with evals in place, and skip semantic caching unless your own tests prove it safe. In the worked example, those steps took the bill from $4,200 to about $711 a month.
Subscribers face the same economics, measured in usage limits instead of dollars. Lean context, the right model, and fewer wasted turns stretch a plan just as they shrink a bill.
Prices and features change quickly, sometimes overnight, as the Gemini increase on December 1 showed. Re-check your vendor’s pricing page before you plan around any number here, and treat these figures as accurate as of early December 2026.
18. References
Pricing and features
- Claude: Pricing
- Claude: Prompt caching
- Claude: Batch processing
- OpenAI: Pricing
- OpenAI: Prompt caching
- OpenAI: Batch API
- Google: Gemini API pricing
- Google: Context caching
Subscriptions
- Claude: How do usage and length limits work?
- Claude: Usage limit best practices
- Claude: Use Claude Code with your Pro, Max, or Ultra plan
- Claude: Manage usage credits for paid plans