Understanding Cache Hit Billing in LLM API Price Cuts

    This article breaks down the billing logic behind cache hit input pricing for large language model services, using a recent price adjustment as the starting point. It explains why input costs split into hit and miss rates, how prefix-based matching determines cache hits, and how to design stable prompt layers to maximize reuse. Readers will find a formula for quantifying cost savings by hit rate, common pitfalls that break the cache, and a practical checklist for implementation.

    1. Background: The Technical Signal Behind a Price Cut

    A cloud provider’s model-as-a-service platform recently announced that, starting at 00:00 Beijing time on November 23, 2026, it would lower the cache hit input price for a large language model service in one regional node to 20% of the original rate, while keeping all other billing items unchanged. The real technical significance of this brief announcement is not the price reduction itself, but that it pushes a long-overlooked component of LLM inference cost structure—cache hit input billing—to the center of engineering decisions.

    For developers and enterprise users, this means two things. First, input-side cost is no longer a constant coefficient but a variable strongly tied to how requests are constructed. Second, cost optimization shifts from “choosing a cheaper model” to “making the same request hit more reusable context.” This article strips away product-specific details and focuses on general technical principles.

    2. Billing Model Breakdown: Why Input Has Two Prices

    Input billing for mainstream LLM services can usually be abstracted as follows:

    1. Total cost = Unmatched input tokens × unit_price_miss
    2. + Matched input tokens × unit_price_hit
    3. + Output tokens × unit_price_output

    Here, unit_price_hit is typically significantly lower than unit_price_miss, and this adjustment targets that item. To understand the rationale, we need to return to resource consumption on the inference side:

    • Miss path: The server must perform full attention computation and a complete forward pass over all inputs, consuming the most compute and memory bandwidth.
    • Hit path: If the request prefix matches cached content, the server can reuse previously computed intermediate states and only incrementally compute the new suffix, sharply reducing compute consumption.

    Therefore, lowering the hit price essentially passes the real upstream resource savings through to billing. The engineering implication is clear: the stability of the request prefix is directly equivalent to cost efficiency.

    3. How Cache Hits Are Determined: Prefix Matching, Not Semantic Similarity

    A common misconception needs clarification: a cache hit is not about “similar content” or “close topics,” but strict token sequence prefix identity. The process can be summarized as:

    1. After a request arrives, it is tokenized into a token sequence;
    2. Starting from the beginning of the sequence, it is compared token by token against existing cache entries;
    3. The portion before the comparison breaks is treated as a hit; the rest is billed as a miss and participates in incremental computation;
    4. Cache entries are subject to lifecycle and capacity constraints; once expired or evicted, they must be rebuilt.

    This yields three hard engineering constraints:

    • Order sensitivity: Swapping the order of any leading sections invalidates everything after them.
    • Longest common prefix principle: The hit length equals the longest common prefix from the start; a single change “truncates” all subsequent benefits.
    • Dynamic content goes last: Content that changes every time, such as timestamps, random IDs, and user session numbers, must be placed at the end of the prompt.

    4. Layered Design for a Stable Prefix

    A high-quality implementation typically divides the prompt into four layers, ordered from stable to volatile:

    1. [Layer 1] Role and global rules (almost never change)
    2. [Layer 2] Domain knowledge and long documents (updated by version)
    3. [Layer 3] Few-shot examples and output format constraints (low-frequency changes)
    4. [Layer 4] Dynamic input for the current task (changes every request)

    Version management is equally critical. It is recommended to establish explicit version numbers for Layer 2 knowledge content and replace it wholesale on changes rather than editing locally:

    1. PROMPT = build_prompt(
    2. system_rules=RULES_V3, # low-frequency changes
    3. knowledge=KNOWLEDGE_2026_11, # versioned, replaced wholesale
    4. examples=FEW_SHOT_SET_B, # changes require hit-rate regression evaluation
    5. dynamic=task_payload, # must be placed at the end
    6. )

    If local editing causes the prefix to break in the middle, the request cannot share a cache with any previous request, and the hit rate drops off a cliff.

    5. Quantifying the Benefit: Converting Hit Rate into Cost

    Let the total input tokens be T, the hit ratio be h, and the hit price discount be d (in this scenario d = 0.2). The ratio of input-side cost to the original cost is:

    1. r = (1 - h) + h × d = 1 - h × (1 - d)

    Substituting d = 0.2:

    • When h = 0, r = 1.0, no benefit;
    • When h = 0.5, r = 0.6, a 40% reduction in input cost;
    • When h = 0.8, r = 0.36, a 64% reduction in input cost;
    • When h = 1.0, r = 0.2, the discount ceiling.

    This linear relationship gives a clear optimization priority: the marginal benefit of improving the hit rate is more pronounced when the original discount is lower. It also serves as a reminder that the overall bill includes output-side costs. If output tokens make up a high proportion, the absolute benefit of input-side optimization is diluted, so cost structure attribution should be done first before deciding where to invest.

    6. Common Pitfalls and How to Avoid Them

    • Embedding variables in the prefix: Writing a user ID or timestamp into system rules zeroes out the hit rate. The fix is to centralize dynamic fields and enforce placing them last.
    • Frequently rotating example sets: Constantly swapping few-shot examples in pursuit of quality sacrifices stability. Treat example sets as versioned assets and decide when to upgrade through offline evaluation.
    • Cross-tenant contamination risk: In shared cache scenarios, confirm the server’s isolation boundary; sensitive data should not be placed in a reusable prefix.
    • Watching only unit price, not hit rate: A price cut does not change the fact that the unmatched portion is billed at the original rate; the hit rate remains the first lever.
    • Lack of observability: Instrument requests to track hit length and token composition; otherwise optimization cannot be verified.

    7. Implementation Checklist

    1. Take a token-level snapshot of existing prompts and confirm whether the first N tokens are constant;
    2. Build a hit rate and cost dashboard, attributed by business line;
    3. Version the knowledge base, rules, and examples separately, with changes going through review;
    4. Compare hit rates before and after changes in a canary environment to prevent regressions;
    5. Evaluate the proportion of output-side costs to avoid misaligned optimization direction;
    6. When selecting architecture, list “support for context reuse billing” as a general evaluation item rather than binding to a specific service.

    8. Conclusion

    The real lesson from this price adjustment is that cost governance for LLM inference has entered a refined stage. Cost is no longer determined solely by “call volume × unit price” but is jointly determined by request construction quality. Treating prompts as engineering assets that require version management and observability, and trading a stable prefix for a high hit rate, is a general cost-reduction path that holds true in any cloud environment.