LLM API Price Cuts: How Prefix Cache Hits and Billing Work

    This article breaks down the billing logic behind a recent LLM service price reduction, where cached input tokens are charged at 20% of the original rate. It explains how prefix caching reuses KV Cache during the prefill stage, what conditions cause cache hits or invalidation, and how total cost is calculated. You will also find the business scenarios that benefit most, practical engineering techniques such as prompt layering, versioning, session affinity routing, observability, and capacity trade-offs, plus common pitfalls and a deployment checklist.

    1. Background: A Typical LLM Service Price Adjustment

    A cloud provider’s model-as-a-service (MaaS) platform recently announced a price reduction for one of its LLM services deployed in a specific region, effective November 23, 2026, 00:00 (Beijing time). The core change is a single item: input tokens that hit the cache are now priced at 20% of the original rate, while all other billing items remain unchanged.

    The announcement is short but dense with information. It signals at least three things:

    1. Billing dimensions are becoming more granular. Input tokens are no longer a single price but are split into “cache hit” and “cache miss” tiers.
    2. Regional pricing is becoming the norm. Limiting the adjustment to a specific region suggests that underlying compute costs and cluster utilization vary by region.
    3. Part of the cost-control initiative is handed back to developers. Whether you get the discount depends on whether a request hits the cache, and the hit rate can be significantly influenced through engineering effort.

    For developers, what deserves attention is not “how much the price dropped” but how the cache hit mechanism works, how to trigger it reliably, and how to adapt the architecture on the business side. The rest of this article follows that thread.

    2. Prompt Cache Hits: Principles and Billing Model

    2.1 What Is Prefix Caching

    LLM inference has two stages: prefill and decode. The prefill stage runs all input tokens through the model once, computing the key-value pairs (KV Cache) for each position. This is a compute-intensive operation and the main source of latency and cost in long-context scenarios.

    The core insight of prefix caching is this: if multiple requests share an identical input prefix, the KV Cache for that prefix can be reused without recomputation. The cached portion is prefilled only once; subsequent requests read the existing intermediate state directly.

    Therefore, “cache hit input” essentially refers to the tokens whose instruction prefix is reused. Their marginal compute cost is far lower than the first computation, which makes the price reduction a natural outcome.

    2.2 Hit Conditions and Invalidation Scenarios

    In practice, a prefix cache hit usually requires the prefix to be token-for-token identical. The following operations all cause cache invalidation:

    • Inserting a timestamp, random ID, or request sequence number at the very beginning of the prompt;
    • Changing any character in the system prompt, including spaces and punctuation;
    • Switching the model version or adjusting parameters that affect tokenization;
    • The prefix length exceeding the cache capacity limit and being evicted by an LRU-like policy;
    • The request being routed to an instance that does not hold the cache.

    Understanding these invalidation conditions matters far more than remembering “there is a discount.”

    2.3 An Abstract Billing Model

    Total cost can be described with a simplified formula:

    1. Total cost = hit input tokens × unit price × discount factor
    2. + miss input tokens × unit price
    3. + output tokens × output unit price

    With a discount factor of 0.2, the input cost of the hit portion drops to one fifth. Assume an application has an input-to-output token ratio of about 4:1 and the prefix accounts for 70%. Overall input cost can then fall by roughly 56%. This shows that the gain does not come from the price cut itself, but from the combination of “high prefix ratio + high hit rate.”

    3. Business Scenarios That Benefit Naturally

    • Chat applications with a fixed system prompt. Role definitions, safety policies, and output format constraints are often thousands of tokens long and identical on every request, making them the ideal cacheable prefix.
    • Repeated Q&A over long documents. Placing the document in the prefix position lets multiple rounds of questions about the same document share the cache.
    • Code completion and AI coding tools. Repository context, coding conventions, and file header comments are highly stable.
    • Batch structured extraction. The same extraction instructions process thousands of records, and the instruction portion is fully reused.
    • Multi-turn agent pipelines. System-level tool descriptions and workflow constraints stay unchanged while only the trailing user input varies.

    Conversely, if every request’s input is free-form user text with no shared prefix, the caching mechanism brings almost no benefit. In that case, optimization should shift to context trimming and model size selection.

    4. Practical Engineering Techniques

    4.1 Prompt Layering: Put Stable Content First

    Divide the prompt into three layers, in a fixed order:

    1. [Layer 1: Stable] Role definition, safety boundaries, output spec, tool descriptions
    2. [Layer 2: Semi-stable] Knowledge base snippets, long document body, few-shot examples
    3. [Layer 3: Dynamic] Current user input, timestamps, session metadata

    Dynamic content always goes last. A common anti-pattern is putting the current time at the beginning, which invalidates the entire prefix on every request.

    4.2 Templating and Version Control

    Treat prompts like code: put them under version control, review changes, and roll them out gradually. Any change to the stable layer is equivalent to a full cache invalidation and should be released during off-peak hours.

    1. SYSTEM_PROMPT_V3 = """You are an enterprise knowledge base assistant.
    2. Answer only based on the provided material; do not fabricate.
    3. Output in Markdown, with the conclusion first.
    4. Material:
    5. {context}
    6. """
    7. def build_messages(context: str, question: str):
    8. # Stable layer first, dynamic layer last
    9. return [
    10. {"role": "system", "content": SYSTEM_PROMPT_V3.format(context=context)},
    11. {"role": "user", "content": question},
    12. ]

    4.3 Session Stickiness and Routing Affinity

    Caches are usually bound to a specific instance. If the gateway randomly distributes consecutive requests of the same session across different instances, the hit rate is severely diluted. In practice, consistent hashing or session-ID affinity routing can keep the same prefix on the same instance as much as possible.

    4.4 Observability: Measure First, Then Optimize

    There is no optimization without measurement. Collect at least the following metrics:

    • Cache hit rate (broken down by business line, model, and region);
    • Input/output token distribution and prefix length distribution;
    • Cost per request and P95 latency;
    • Cache eviction count and capacity watermark.

    You can build dashboards with general-purpose logging and monitoring/alerting capabilities, and set threshold alerts for abnormal drops in hit rate. A sudden drop in hit rate often means someone changed the system prompt.

    4.5 Cost and Capacity Trade-offs

    Caching requires GPU memory or memory space, and capacity is limited. If a business has too many prefix variants (for example, an ultra-long prompt per tenant), eviction intensifies. In that case, evaluate consolidating prompt templates, compressing context, or deliberately giving up caching for low-frequency long prefixes.

    5. Common Pitfalls

    1. Assuming a price cut automatically saves money. The discount applies only to the hit portion, so the hit rate remains the primary variable.
    2. Putting dynamic information in the prefix. A single timestamp can reduce the benefit to zero.
    3. Ignoring tokenization boundaries. If string concatenation changes token splitting, prefix consistency is broken. Structured templates are more reliable than raw string concatenation.
    4. Comparing unit prices across regions. Price adjustments often apply to a single region, so costs must be calculated for the region where the business is actually deployed.
    5. Looking only at unit price, not architecture. Context trimming, model tiering, and batch merging can sometimes yield more than the unit price discount itself.

    6. Implementation Checklist

    • Has the prompt been reordered into stable / semi-stable / dynamic layers?
    • Is the stable layer under version control with gradual rollout support?
    • Does the gateway support session affinity routing?
    • Are dashboards in place for hit rate and cost per request?
    • Are alerts configured for drops in hit rate?
    • Are real costs calculated per deployment region?
    • Is the number of long prefixes controlled to avoid frequent eviction?

    7. Conclusion

    The technical meaning of this price adjustment is turning “inference cost” from an uncontrollable black box into a variable that can be actively managed through prompt engineering and traffic scheduling. For developers, the best investment is not chasing a single price-cut announcement but building a context organization approach that is cacheable, measurable, and governable. When the hit rate becomes a core metric that is continuously monitored, cost optimization turns from a one-off activity into a long-term capability.