Why Are LLM Bills Exploding? Token Caching and Routing for Cost Control

    A practical guide to why large language model bills grow unexpectedly, and how to control them. It explains how token structure, unused caching, and missing routing drive up costs, how to read model pricing tables, how to break down per-request costs, and how to apply prefix caching, task routing, budget guardrails, and a deployment checklist.

    1. Why Bills Explode: It’s the Structure, Not the Unit Price

    When teams see their first large language model bill, the reaction is usually the same: “The unit price isn’t high, so why is the total so extreme?” The root cause is rarely the unit price. It is usually three structural factors stacking together:

    1. Imbalanced token consumption: Output tokens often cost several times more than input tokens. Long-form generation, repeated rewrites, and full-document summarization can quickly inflate spending.
    2. Caching is not being used effectively: System prompts, tool definitions, and knowledge base snippets are repeatedly sent in full without hitting the cache, which means paying full price every time.
    3. No routing strategy: Every request goes to the strongest model. Simple classification, format conversion, and extraction tasks also use high-cost models.

    In other words, the first step in cost control is not cutting the unit price. It is breaking the bill down into dimensions you can attribute.

    2. Using the Current Model as a Sample: How to Read a Price Table

    A common industry practice is to start with a “representative model price example” to build calculation intuition. The table below only demonstrates the calculation method, with units per 1 million tokens. Specific models and unit prices change with iterations, so before a production launch you should rely on the vendor’s console.

    Vendor type Representative model tier Input price Cache hit price Output price Suitable scenarios
    A cloud vendor Flagship inference tier 5.00 0.50 30.00 Complex reasoning, agents, code, critical business
    A cloud vendor Lightweight tier 0.75 0.075 4.50 Medium tasks, summarization, general generation
    A cloud vendor Long-task tier 5.00 0.50 25.00 Long context, complex code, agent workflows
    A cloud vendor Multimodal tier 2.00 / 4.00 0.20 / 0.40 12.00 / 18.00 Multimodal, long context
    A cloud vendor High-concurrency tier 0.50 0.05 3.00 Customer service, classification, light reasoning

    There are three key takeaways. The cache hit price is usually only about one tenth of the input price. The multiple between output price and input price means generative tasks are inherently more expensive. And the total price difference between tiers can exceed ten times, so the leverage from routing is far greater than the leverage from negotiation.

    3. How to Break Down Token Billing Correctly

    The cost of a single request can be abstracted as:

    1. cost per request = input tokens × input price
    2. + cached tokens × cache price
    3. + output tokens × output price
    4. + routing/retrieval and other overhead

    This gives three optimization levers:

    • Compress input: Rewrite lengthy background into a structured summary, and replace “full document” with “retrieved snippets plus citation locations”.
    • Control output: Set a cap on generation length, use strict mode for structured output, and avoid extra tokens from the model “freely improvising”.
    • Improve cache hits: Put stable, unchanging content (system instructions, tool descriptions, glossaries, long document prefixes) at the front of the prompt, keep the prefix byte-for-byte identical, and avoid inserting volatile content such as timestamps or random IDs that break the cache.

    Illustrative code (pseudocode, expressing the idea only):

    1. def build_prompt(system_block, retrieved, user_input):
    2. # system_block must stay unchanged to hit the prefix cache
    3. return f"{system_block}\n[CTX]{retrieved}\n[Q]{user_input}"

    4. Cache Governance: Turning Repeated Payments into a One-Time Investment

    The essence of caching is “trading consistency for price”. Engineering-wise, four points matter:

    1. Prefix stability: Caching usually matches by prefix, so any single change invalidates the entire segment.
    2. Lifecycle management: Caches have a time-to-live. Batch jobs should be scheduled together to avoid scattered requests crossing the expiration window.
    3. Observability: Report the cache hit rate as a core metric into the monitoring and alerting system. A sudden drop in hit rate often means the prompt template was changed.
    4. Cost attribution: The bill needs to be tagged by business line, scenario, and model tier. Otherwise you cannot tell whether optimization is actually working.

    5. Routing Strategy: Sending Each Request Type to the Right Price Tier

    Routing is the biggest lever for bringing costs down. It is recommended to grade requests along two dimensions: task difficulty and cost of failure.

    • High difficulty, high cost of failure: Complex reasoning, code generation, critical business decisions → flagship tier.
    • Medium tasks: Summarization, rewriting, routine Q&A → lightweight tier or high-concurrency tier.
    • Deterministic tasks: Classification, extraction, format validation → a small model, or even a rule engine as a fallback.
    • Failure is retryable: Run a small model first, and escalate to a large model when confidence is insufficient, forming a cascade.

    Pseudocode for the cascade:

    1. def route(task):
    2. if task.difficulty <= 1 and task.risk == "low":
    3. return small_model(task)
    4. draft = small_model(task)
    5. if draft.confidence > 0.85:
    6. return draft
    7. return flagship_model(task)

    6. Cost Guardrails and Operating Mechanisms

    For a technical solution to land, it must be paired with mechanisms:

    • Budgets and quotas: Set daily/monthly budgets and token quotas by team, environment, and scenario. Downgrade or queue when limits are exceeded.
    • Load testing and capacity planning: Run cost load tests with real traffic distribution rather than estimating with average length.
    • Data loop: Send request logs, token usage, and hit information into a unified logging service and object storage, and periodically review abnormal growth.
    • Architecture-side optimization: Cache results in front for high-frequency repeated Q&A; put batch jobs into a message queue to smooth peaks, and use container platform elastic scaling to absorb traffic spikes.

    7. Deployment Checklist

    1. Have you built a billing dashboard across the four dimensions of input/output/cache/routing?
    2. Is the stable prefix being polluted by volatile content?
    3. Is there a mismatch where “simple tasks use the flagship model”?
    4. Is there a hard cap on output length and structured constraints?
    5. Are there budget guardrails, downgrade strategies, and alert thresholds?
    6. Do you review the price and tier mapping once per quarter?

    Conclusion

    Large model cost control is not a one-time price cut. It is a continuously running engineering loop: use the correct pricing model for attribution, use caching to trade for unit price, use routing to trade for structure, and use guardrails to trade for predictability. Do these four things solidly, and the bill turns from an uncontrollable “black box expense” into a technical metric you can optimize by scenario and operate by budget.