LLM API Cache Hit Pricing: How Prompt Caching Cuts Input Costs

    This article explains a recent structural price reduction on cached input tokens for a general-purpose LLM API, and what it means for engineering teams. It covers how prompt caching works at the prefill and decode stages, why only the prefix KV cache is reused, and how to model per-request cost with hit rate and discount rate as variables. It also outlines which workloads naturally achieve high hit rates, design rules for structuring prompts to maximize reuse, correctness and security boundaries, a four-step validation process before rollout, and common misconceptions about caching savings.

    1. Background: A Structural Price Cut, Not a Broad One

    A cloud provider’s model-as-a-service (MaaS) platform announced that, starting November 23, 2026 at 00:00 (Beijing time), it will reduce selected billing items for a general-purpose LLM service in a specific region: the input portion that hits the cache will be billed at 20% of the original price, while all other billing items remain unchanged.

    The significance of this news is not the price cut itself, but where the cut lands. Only the “cache-hit input” item was changed, which signals that the billing model is moving away from a flat rate based on token length toward tiered pricing based on whether computation is reused. For developers, this means a new variable has appeared in the bill structure that can be actively tuned through engineering: previously you could only save money by shortening prompts; now you can also save by increasing the cache reuse rate.

    2. How It Works: What Prompt Caching Actually Caches

    LLM inference has two stages: prefill and decode. The prefill stage runs attention computation over all input tokens and generates the key-value cache (KV Cache) for each position; the decode stage reuses that KV Cache to produce output token by token. The bulk of the cost is usually in prefill, because its computation is roughly proportional to input length and it is the most matrix-parallel, compute-intensive part.

    Prompt caching keeps the KV Cache of the “prefix” on the service side for a period of time. When a new request’s prefix exactly matches a cached prefix, it is reused directly, skipping the repeated computation. This clarifies two commonly misunderstood points:

    • The cache granularity is the prefix, not arbitrary fragments. Hit detection typically compares token by token from the start of the sequence; everything after the first mismatch cannot be reused.
    • What is cached is intermediate computation, not the final answer. It does not make the model “remember” your question, nor does it change output variation caused by sampling randomness.

    So “cache-hit input priced at 20% of the original” essentially returns the saved prefill compute to the caller in the form of a discount.

    3. Cost Model: Breaking the Bill into Four Variables

    To judge whether this price cut matters to you, first express the cost of a single request in an analyzable form:

    1. cost per request ≈ input tokens × input price × (1 - hit rate × (1 - discount rate))
    2. + output tokens × output price
    3. + fixed call overhead

    Here the discount rate is 0.2 (the hit portion is billed at 20%). Example: a request with 4,000 input tokens and 500 output tokens, with the hit rate rising from 0 to 0.8, gives an effective input price of 0.2 × 0.8 + 1.0 × 0.2 = 0.36, a drop of about 64% on the input side. The overall bill reduction depends on the input-to-output ratio. The higher the input share and the more stable the prefix, the more obvious the benefit; conversely, if every request is a brand-new short prompt, you get almost no discount.

    Note that the discount rate, the region where it applies, and the effective time are platform-side policies that can change at any time. Do not hardcode a specific value into your budget model; make it a configuration item instead.

    4. Which Workloads Fit Naturally: Four High-Hit Scenarios

    1. Long system prompts and role definitions. Customer service, moderation, and shopping-guide applications often have thousands of tokens of fixed persona and rules, with a natural hit rate close to 1.
    2. Large-scale document or knowledge-base Q&A. Using a long document as a stable prefix and asking consecutive questions about the same document means nearly full hits from the second question onward.
    3. Code and SQL assistance. Repository context, table schema descriptions, and coding conventions are long prefixes that change infrequently.
    4. Batch structured extraction. The same extraction instructions and output schema applied repeatedly across hundreds or thousands of records.

    In contrast, placing the ever-growing full history at the front in a multi-turn conversation makes the prefix change every turn, driving the hit rate toward zero. This is the most common anti-pattern of “having a cache but saving nothing.”

    5. Implementation: Design Rules for Higher Hit Rates

    The core principle is one sentence: keep the things that change as far back as possible.

    • Prefix layering: stable layer (rules, examples, documents) → semi-stable layer (user profile, session summary) → volatile layer (current question, timestamps, random IDs). Never put random numbers, millisecond timestamps, or request IDs at the start of the prompt.
    • Template convergence: use a unified template and consistent placeholder order within the same business, and avoid A/B experiments creating multiple prefixes that fragment the cache.
    • Fixed ordering: sort retrieval results by a stable rule (such as document ID) rather than by floating-point similarity, to avoid ordering jitter that breaks the prefix.
    • Change cadence: consolidate frequently adjusted content into periodic updates. Hit rate is inversely correlated with update frequency, so freshness must be traded off.
    • Session strategy: in multi-turn scenarios, switch to a “fixed summary + most recent turns” structure so the prefix stays stable and only the tail grows.

    Illustrative pseudocode:

    1. def build_prompt(system_rules, doc_context, profile, question):
    2. # Order is priority: the more stable, the earlier
    3. return "\n".join([
    4. system_rules, # stable layer, unchanged long-term
    5. doc_context, # semi-stable layer, cached per document
    6. profile or "", # volatile layer
    7. question, # latest input
    8. ])

    6. Correctness and Security Boundaries: Three Things a Discount Cannot Buy

    • Consistency risk: caching matches by prefix. If two pieces of business content differ in meaning but share identical prefix text, the wrong context may be reused, causing cross-contamination. In multi-tenant scenarios, put the tenant identifier at the very front of the prefix or rely on platform-side isolation.
    • Data retention concerns: do not put sensitive data in a prefix that will be retained for a long time; sensitive information should come later and follow the principle of least necessity.
    • Freshness risk: prices, inventory, and policy information cached into a prefix will not update automatically. Set an explicit prefix version number and replace the whole thing when it changes.

    7. Validation and Measurement: A Four-Step Assessment Before Launch

    1. Instrumentation: log input tokens, hit tokens (if returned by the platform), output tokens, and latency for each request.
    2. Baseline: run a round with the unoptimized template to get a baseline cost per request.
    3. Comparison: change only the prefix structure while controlling other variables, and compare hit rate and P95 latency.
    4. Regression: verify output quality has not degraded, especially field accuracy for extraction tasks.
    1. hit rate = hit input tokens / total input tokens
    2. effective discount = hit rate × (1 - discount rate)
    3. suggested threshold: for long-prefix scenarios, fix the template first when hit rate < 0.5, rather than scaling up

    8. Common Misconceptions

    • Assuming caching lowers output cost. Output billing is unrelated to the cache.
    • Assuming a hit is free. A hit is only a discount; it is still billed at the discounted price.
    • Assuming it applies across regions. Such adjustments usually apply to a single region, so costs must be accounted for per region in the architecture.
    • Treating the price cut as a substitute for fixing architecture. If the prefix design is messy, no discount can rescue the cost.

    9. Conclusion

    This structural price cut, targeting only cache-hit input, sends a clear signal: LLM call costs are shifting from “billing by length” to “billing by reuse.” The right response for developers is not to wait for the next price cut, but to treat prompts as engineering assets that need version management and layered design: stable prefixes first, volatile content last, measurable hit rates, and regression-testable correctness. With these four points in place, cost optimization becomes sustainable and bill fluctuations become genuinely controllable.