LLM API Price Cuts Explained: The Billing Logic Behind Cache Hits and Prefix Reuse

    This article breaks down why a cloud provider's decision to cut the price of cached input tokens to 20% of the standard rate matters far beyond the discount itself. It explains how large language model inference splits into prefill and decode stages, why identical prefixes allow KV Cache reuse, and how providers determine cache hits through strict prefix matching. You will learn practical rules for structuring prompts by stability layers, differentiated strategies for multi-turn conversations and RAG, the metrics needed to measure hit rate, implementation patterns for stable prefixes with dynamic suffixes, and the capacity, region, and risk considerations that come with prefix caching. The core takeaway: LLM cost is shifting from pay-per-usage to pay-per-reusability, and treating prompts as versioned, layered, append-only assets is how teams capture the savings.

    1. Background: What a Price Cut Signals Technically

    A cloud provider’s Model-as-a-Service (MaaS) platform announced that starting November 23, 2026, at 00:00 (Beijing time), it would lower the price of a general-purpose LLM service deployed in a single region. The adjustment applies only to the “cached input” billing item, which drops to 20% of its original value. All other billing items remain unchanged.

    The information density here is higher than it appears. There are three technical implications:

    1. Billing has become fine-grained. Input is no longer a single “per thousand tokens” rate; it is split into cached and uncached categories.
    2. The inference cost structure is now publicly acknowledged. Reusable intermediate computation exists on the server side, and the compute saved is returned to callers in the form of lower prices.
    3. Region-based pricing is becoming standard. The same model can be priced differently across regions due to differences in power, compute supply, and network costs, so architecture decisions must account for region.

    For developers, the real action item is not “wait for the price cut.” It is to understand why a cache hit produces a multiples-level cost difference, and to proactively reshape workloads into high-hit-rate forms.

    2. LLM Inference Cost Structure: Why Input Can Be Discounted

    A typical decoding process has two stages:

    • Prefill: A parallel forward pass over all input tokens, generating the key-value pairs (KV Cache) for each layer. Compute is roughly linear in input length, and the stage is memory-bandwidth intensive.
    • Decode: Token-by-token autoregressive generation, where each step reads the accumulated KV Cache from prior steps. This is a classic memory-bound bottleneck.

    The key point: if two requests share an identical prefix, the KV Cache for that prefix does not need to be recomputed and can be reused directly. What is saved is the compute and memory-bandwidth overhead of the prefill stage. This is the physical basis for pricing “cached input” separately and discounting it heavily.

    So the essence of cache hit rate is not “network caching” but prefix-level compute reuse rate. Once this is clear, every optimization technique that follows makes sense.

    3. Hit Determination Rules: The Strict Prefix Matching Model

    Mainstream implementations follow consistent prefix-matching semantics, which can be abstracted into these rules:

    • Treat the request’s input sequence (system instructions + conversation history + current question) as a whole, and compare token by token from the first token;
    • Hit length = the longest common prefix length with a cached sequence;
    • Only the portion where hit length is greater than zero counts as “cached input”; the rest counts as uncached input;
    • Cache entries have a time-to-live (TTL) and are bounded by capacity, using eviction policies such as least recently used (LRU);
    • Once any position in the prefix changes, everything after it degrades to uncached.

    The last rule is the most overlooked: the earlier a change occurs, the greater the loss. Putting volatile content at the start of a prompt means continuously giving up the discount.

    4. Four Practical Rules for Prompt Structure Design

    To keep the hit rate consistently high, reorder the prompt by “decreasing stability”:

    1. Invariant layer: role definition, output format constraints, safety policies, glossary, tool declarations.
    2. Low-frequency layer: domain knowledge, long documents, codebase context, few-shot examples.
    3. Session layer: multi-turn history, appended per turn, naturally satisfying append-only prefix semantics.
    4. High-frequency layer: the user’s current-turn input, timestamps, random identifiers, retrieval results.

    An illustrative structure (pseudocode, showing order only):

    1. [Invariant] System instructions + output schema + safety constraints
    2. [Low-frequency] Domain knowledge block + reference docs + examples
    3. [Session] History messages 1..n (append only, no rewrite)
    4. [High-frequency] Current user input + dynamic variables

    Three supporting disciplines:

    • Always place dynamic variables at the end; never insert timestamps or request IDs at the front;
    • Use append mode for history; do not “summarize and rewrite” completed turns, as that breaks the prefix;
    • Ensure template rendering is byte-level stable, avoiding meaningless jitter from dict iteration order, float formatting, or whitespace.

    5. Differentiated Strategies for Multi-Turn and RAG Scenarios

    Multi-turn conversation is the biggest beneficiary of the caching mechanism. The nth request contains all content from the previous n-1 turns, so the hit rate rises monotonically with turns, and the marginal cost of long sessions drops significantly. Engineering-wise, treat session history as an append-only log.

    Retrieval-Augmented Generation (RAG) is the opposite. If retrieval results differ each time and are concatenated at the front of the prompt, the hit rate approaches zero. Viable changes include:

    • Move the stable knowledge base (high-frequency documents that rarely change) to the front as a cacheable prefix;
    • Put the fragments retrieved for the current request at the tail of the prompt;
    • Introduce semantic-level caching for high-frequency questions, reusing complete answers on the application side and bypassing repeated inference;
    • Normalize and denoise retrieved fragments with consistent ordering to reduce pointless prefix changes.

    6. Observability and Hit Rate Measurement

    Optimization must be measurable. Recommended metrics to collect and put on a dashboard (using general capabilities: log services, monitoring and alerting, message queues for async instrumentation aggregation):

    • Cache hit rate = cached input tokens / total input tokens;
    • Average hit prefix length and number of hit entries;
    • Latency distribution caused by cache misses (P50/P95/P99);
    • Cost per request and cost per thousand sessions;
    • Eviction rate and the share of invalidations caused by TTL expiry.

    A simplified cost estimate:

    1. Input cost per call ≈ hit tokens × hit price + uncached tokens × standard price
    2. Discount benefit ≈ hit tokens × (standard price − hit price)

    When the hit price drops to 20% of the standard price, a 70% hit rate compresses input-side cost to roughly 44% of the standard value. The magnitude is substantial.

    7. Implementation Notes

    API shapes differ across providers, but the engineering actions are highly consistent and can be abstracted into a general flow:

    1. # Pseudocode: the "stable prefix + dynamic suffix" calling pattern
    2. SYSTEM_PROMPT = "You are a rigorous technical assistant. Output must be JSON and follow safety policies..." # Invariant layer
    3. KNOWLEDGE = load_knowledge_base() # Low-frequency layer, updated periodically
    4. def build_messages(history, query, dynamic_ctx):
    5. messages = [{"role": "system", "content": SYSTEM_PROMPT}]
    6. messages.append({"role": "system", "content": KNOWLEDGE})
    7. messages.extend(history) # Append only
    8. messages.append({"role": "user",
    9. "content": f"{query}\n<ctx>{dynamic_ctx}</ctx>"})
    10. return messages
    11. def estimate(usage):
    12. hit = usage.get("cached_input_tokens", 0)
    13. total = usage.get("prompt_tokens", 0)
    14. return {"hit_ratio": hit / max(total, 1), "hit_tokens": hit}

    Implementation also requires: extracting input token and cached token fields from the response for closed-loop validation; versioning long documents and proactively warming the cache when a version changes; and canary-releasing prompt templates to avoid a cliff-edge drop in hit rate from a full switch.

    8. Capacity Planning, Region, and Risk Notes

    • Region selection: This adjustment covers only a single region, indicating price varies by region. Latency-insensitive, cost-sensitive batch pipelines can prioritize lower-priced regions; interactive pipelines must weigh network latency.
    • Cache is not strongly consistent: Hits depend on TTL and capacity eviction. Do not treat the cache as business state storage; correctness must be guaranteed by explicit context.
    • Privacy and isolation: For multi-tenant shared cache implementations, confirm prefix isolation mechanisms. Sensitive data should not rely on the cache layer as an isolation boundary.
    • Regression testing: Compare hit rate and output quality before and after template changes to prevent “saving money but degrading quality.”
    • Budget guardrails: Set cost alerts and quotas to avoid sudden bill spikes when the hit rate drops.

    9. Conclusion

    The real lesson from this price adjustment: LLM invocation cost has evolved from “pay per usage” to “pay per reusability.” Governing prompts as software assets with a lifecycle, layered, versioned, measurable, and append-only, is how you sustain a multiples-level cost advantage at the same business quality. The recommended actionable path: first add hit-rate instrumentation and dashboards, then reorder prompt layers, and finally run targeted改造 on session and retrieval pipelines to form a closed optimization loop.