Why LLM Bills Spike: Cost Control from Metering to Routing
LLM bills can rise even when user traffic is flat, because one business request may trigger multiple model calls, longer context, retries, and higher-cost models. This article explains how to separate business requests from model calls and billed usage, model token cost correctly—including cache hits—and govern input, caching, output, routing, multi-step workflows, and observability without sacrificing result quality.
1. Why the Bill Spikes: A Business Request Is Not a Model Call
A single user question may look like one request at the application layer, yet the system may run intent detection, knowledge retrieval, answer generation, result checks, and failure retries. If the system also uses an agent that plans and calls tools on its own, one business request can trigger even more rounds of model interaction.
Cost analysis therefore needs three distinct layers:
- Business request: one user action, such as submitting a question or generating a report.
- Model call: one inference request the system actually sends to a model.
- Billed usage: input, output, and any other resources charged under the service’s billing rules for that call.
These layers are not one-to-one. Request volume can stay flat while the bill rises because each request triggers more calls, conversation history grows, or more requests are routed to a higher-cost model.
A useful approximation for diagnosis is:
Total cost ≈ business request volume × average calls per request × average cost per call.
This is not an exact billing formula, but it quickly points to the source of growth. The first step in cost control is not to hunt for a cheaper model. It is to see which path, which step, and which request type the money is spent on.
2. Build a Correct Token Cost Model First
2.1 A token is neither a character count nor a word count
A token is the unit a model uses when it processes text and related inputs. Text is usually tokenized into a sequence, but counts differ by language, content, and tokenizer.
Do not assume that one Chinese character equals one token, and do not use a fixed ratio to convert all code, numbers, tables, and natural-language text. Images, audio, and other non-text inputs may be metered differently.
In production, prefer the usage figures the service actually returns. If you must estimate before a request, use a method that matches the target model and leave room for error.
2.2 Price uncached input, cached input, and output separately
Under a common per-token pricing model:
Cost of one call = uncached input tokens ÷ 1,000,000 × input price
- cached input tokens ÷ 1,000,000 × cache-hit price
- billed output tokens ÷ 1,000,000 × output price
- any other applicable charges.
Two mistakes are easy to make.
First, cached input is part of total input. Do not charge it again as ordinary input. Second, billed output is not necessarily only the final text the user sees. Some services meter reasoning or similar consumption on an extra or different basis. Follow the actual rules and bill fields.
If the service charges for cache writes, cache storage, tool calls, retrieval, image processing, or other items, include those in the cost model separately. Do not mix rules from different services.
2.3 A price table is a worked example, not a permanent result
Model capability, how a service is supplied, and billing policy keep changing. A cost-control system should keep an updatable price configuration instead of hard-coding unit prices in application code.
The prices below are entirely hypothetical. They only show the calculation method and do not represent any real service quote. All units are per million tokens:
| Capability tier | Standard input | Cache hit | Output | Typical tasks |
|---|---|---|---|---|
| High capability | 5 yuan | 0.5 yuan | 30 yuan | Complex reasoning, important decision support, hard coding tasks |
| Balanced | 1 yuan | 0.1 yuan | 6 yuan | Routine generation, summarization, general Q&A |
| Lightweight | 0.5 yuan | 0.05 yuan | 3 yuan | Classification, field extraction, simple rewriting |
When you compare real options, also check whether context length, processing mode, service region, or usage tier changes the price basis.
3. A Worked Example of Cost Amplification
Suppose an application handles 10,000 requests a day, and each request calls the high-capability model once:
- Total input is 8,000 tokens.
- Output is 1,000 tokens.
- There is no cache hit.
- Prices are the hypothetical values above.
Cost per call:
8,000 ÷ 1,000,000 × 5 + 1,000 ÷ 1,000,000 × 30
= 0.04 + 0.03
= 0.07 yuan.
Daily model cost is 700 yuan.
If a new workflow makes each business request trigger three calls on average, and each call uses roughly the same volume, daily cost rises to about 2,100 yuan. User request volume did not increase, but cost tripled.
Now suppose 6,000 input tokens hit the cache and the remaining 2,000 are billed as standard input. Cost per call becomes:
2,000 ÷ 1,000,000 × 5
- 6,000 ÷ 1,000,000 × 0.5
- 1,000 ÷ 1,000,000 × 30
= 0.043 yuan.
Compared with 0.07 yuan without a cache, that is about a 38.6% reduction per call. Caching can cut input cost substantially, but it does not remove output cost, and it does not replace governance of the call path.
This calculation also assumes every cached input actually hits and that there are no extra cache fees. Real savings must be checked against actual usage and billing rules.
4. Input Control: Cut Useless Context, Not Context Blindly
4.1 Budget each part of the context
Typical input can be split into system instructions, conversation history, retrieved material, tool results, and the current question. Each part needs a clear reason to be there and a length budget.
System instructions should state a stable role, rules, and output constraints. Do not stack the same requirement in different words. Conversation history should keep facts, constraints, and unfinished items that matter to the current question, not replay the full record on every turn.
Retrieved material should be filtered for relevance, deduplicated, and length-limited. Tool results should not be pasted in unchanged. If the task only needs status, amount, and time, there is usually no reason to attach the entire returned object.
4.2 Longer context is not higher quality
Longer input raises the input cost of every call and can add latency. Extra material can also make it harder for the model to use the constraints that matter.
Cutting input must not break the task. Contract review and complex code analysis may genuinely need a long context. The right approach is to find the minimum sufficient context through evaluation, not to impose one short length on every task.
Summarizing a conversation also has a cost. If producing the summary costs more than the input it later saves, there is no economic gain. If the summary drops key facts, later corrections and retries add more cost.
5. Cache Control: Know the Cache Type Before You Count the Hit Rate
5.1 Input cache and result cache solve different problems
An input cache usually targets repeated input segments and reduces eligible input-processing charges or overhead. The model may still have to generate an answer.
A result cache reuses an answer that was already generated. When the hit is safe to reuse, the corresponding model call can be skipped. Do not treat the two as the same thing.
Result caching fits tasks with stable inputs and answers, such as common questions against a fixed document version. When the task involves live data, user permissions, or personalized content, the cache key must include data version, identity and permissions, and time to live.
5.2 A stable prefix helps input-cache reuse
For an input cache that matches prefixes, stable content at the front and changing content at the back usually improves reuse.
A practical order is:
Stable instructions → fixed materials and rules → dynamic retrieved content → the current user question.
If every request starts with a random identifier or the current time, later stable content may no longer match. Whether caching is automatic, the minimum length, and the time to live all depend on the service’s rules. Request structure alone does not guarantee a hit.
5.3 Measure token hit rate, not only request hit rate
“How many requests hit the cache at least once” only shows coverage. It does not fully show savings. A more useful metric is:
Cache token hit rate = cached input tokens ÷ total input tokens.
A request can hit a very short fragment and save little. Track hit tokens, actual money saved, and applicable cache write and storage fees together.
Result caches also need invalidation. Reusing an old answer after data, rules, or permissions change can cause a business problem worse than the money saved.
6. Output Control: Limit Length and the Cost of Fixing Mistakes
In many pricing plans, output costs more per token than input. A long answer with no extra value raises the bill directly.
Ask for the fields you need, limit unrelated explanation, avoid restating the input, and set a reasonable output cap. Specifying how many items a list should contain, or how long a summary should be, is usually more controllable than a vague request to “be concise.”
A cap that is too low can truncate the answer. If the user asks again or the system regenerates, total cost can rise. Set different budgets for different tasks, and watch truncation rate, result completeness, and follow-up rate.
Streaming mainly improves perceived latency. It does not by itself reduce token cost. If the user cancels, the application should stop generation that is still running when it can, but the final charge follows when the service actually stops processing.
7. Model Routing: Optimize the Cost of a Successful Task
7.1 Do not send every task to the highest tier by default
Classification, field extraction, simple rewriting, and complex reasoning do not need the same capability. Sending everything to the high-capability tier pays an unnecessary premium for simple work.
Start with task tiers:
- Lightweight: classification, standard field extraction, fixed-format conversion.
- Routine: summarization, knowledge Q&A, general content generation.
- Hard: multi-constraint reasoning, complex code analysis, long-chain planning.
- High risk: business handling that needs strict verification or human review.
Routing rules should use task difficulty, risk, context size, quality requirements, and latency targets—not input length alone.
7.2 Escalation must include the cost of failure
A common pattern is to try a lower-cost model first and escalate if validation fails. That is not automatically cheaper.
Expected cost can be approximated as:
Expected cost = lower-cost model fee + validation fee
- escalation probability × extra cost after escalation.
Suppose the lower-cost attempt plus validation costs 0.015 yuan, and escalation adds 0.07 yuan. At a 20% escalation rate, expected cost is 0.029 yuan. At 90%, it is 0.078 yuan, already above the 0.07 yuan of going straight to the high-capability tier.
Routing needs real task evaluation and production data. Tasks that clearly exceed the lower-cost model should go to the high-capability tier directly.
7.3 Price cannot replace quality constraints
Prefer checks you can verify—field completeness, format checks, rule checks, and test cases—over the model’s own statement of confidence when deciding whether to escalate.
Move the cost metric from “how much each call costs” to “how much each acceptable business result costs”:
Cost per acceptable result = total related cost ÷ number of results that meet the quality bar.
That metric catches the hidden cost of a cheap model: errors, retries, and manual correction.
8. Multi-Step Workflows: Put Hard Limits on Loops and Retries
The main risk in an agent workflow is carrying history forward on every turn while appending new tool results. As turns increase, each turn’s input grows, and cumulative cost can rise faster than the number of calls.
Set limits on execution turns, total token budget, tool-call count, runtime, and repeated failures. For repeated actions, detect whether the system is running the same step again in the same state.
Separate network retries from business retries. Transient failures can be retried a limited number of times. If the result fails a business requirement, identify the cause first instead of resending the same request mechanically.
If the client times out but the server has already run the work, submitting again can duplicate processing. Use a task identifier, execution state, and idempotent design to avoid duplicate cost. Do not treat a client timeout as proof that the work failed.
9. Put Cost Control into Observability and Release
9.1 Record usage at the business level
Each call should be tied to the business request, workflow step, model tier, input tokens, cached tokens, output tokens, call count, failure reason, and estimated cost.
Record metering and trace metadata first. Do not store user text without limit just to reconcile the bill. Sensitive content should follow least-collection, access control, and retention rules.
9.2 Track metrics that explain anomalies
Besides daily total cost, keep watching:
- Average and high-percentile cost per business request.
- Average calls per business request.
- Input and output length distributions.
- Cache token hit rate.
- Share of calls on the high-capability tier.
- Retry rate, escalation rate, and output truncation rate.
- Cost per acceptable result.
High-percentile cost surfaces a few very long contexts or runaway loops. Those outliers can still push the bill up when the average looks stable.
9.3 Compare before and after a release on the same basis
Prompt changes, retrieval changes, routing changes, and new tools can all change the cost structure. Compare quality, latency, and cost on a fixed evaluation set, then validate the real request mix with a small traffic rollout.
Budget control can be staged: alert as you approach a threshold, restrict non-critical work as you get closer to the cap, and stop deferrable work at a hard cap. Degradation or blocking for critical business should be designed in advance. Do not switch everything, on the spot, to a model that cannot do the job.
10. Rollout Order: Measure, Then Optimize, Then Keep Calibrating
A practical cost-control process has four steps:
- Reconstruct the bill. Use one usage definition, and attach model cost to business requests and workflow steps.
- Find waste. Look for long inputs, long outputs, repeated calls, cache misses, and unjustified use of the high-capability tier.
- Validate changes. Try context trimming, caching, output constraints, and model routing separately, and evaluate quality and latency at the same time.
- Lock in the mechanism. Keep versioned price configuration, automated budgets, anomaly alerts, and ongoing evaluation.
LLM cost control is not simply pushing token counts down. It is making sure each input, generation, and call has business value inside a clear quality boundary. Unit prices will change and model capability will change. Accurate metering, less useless consumption, capability matched to the task, and cost measured per acceptable result can still support the system as it scales.
