LLM Prompt Caching Pricing: A Practical Guide to Cutting Input Costs

    This article explains how a price adjustment limited to cached input tokens on a MaaS platform signals a broader engineering opportunity for developers. It breaks down why cache-hit input is cheaper, presents a token-based cost model with an estimation script, and outlines structured practices for raising cache hit rates: layering prompts by stability, keeping prefixes consistent across turns, batching requests, and building observability. It also covers common pitfalls, security considerations, and a practical action checklist that applies to any token-billed LLM service.

    1. Background: What a Targeted Price Change Signals

    A cloud provider recently announced that, effective 00:00 Beijing time on November 23, 2026, it is lowering the price of a lightweight text generation model in its MaaS (Model-as-a-Service) offering in one region. Only one billing item changes: cache-hit input drops to 20% of its original price. Every other billing item stays the same.

    The significance is not the discount itself but its structure. The change touches a single dimension on the input side. Output pricing, cache-miss input pricing, and all non-cache billing items remain unchanged. For developers, this points cost optimization at one specific target: whether the prefix of a request can be reused by the caching system.

    This article does not evaluate or recommend any specific vendor’s product. Instead, it abstracts this kind of billing change into a general engineering problem: in token-billed inference services, how to restructure prompts and call patterns to increase the share of cacheable content and lower the blended cost per business request.

    2. How It Works: Why Cacheable Input Is Cheaper

    Most inference services split input billing into these categories:

    • Cache-miss input: the model must process the full set of prompt tokens. This is the most expensive input category.
    • Cache-hit input: the prefix has been computed before, so the server reuses the intermediate results. This is significantly cheaper.
    • Output: billed per generated token, usually at a higher unit price than input.

    The technical basis is the autoregressive nature of Transformer-style models. When processing a prompt, the model computes Key/Value tensors for every token. If a new request’s prefix is identical to a previous one, that KV state does not need to be recomputed and can be loaded directly, saving real compute and memory bandwidth. Vendors pass part of that saving back as a separate price item for cache-hit input.

    Three engineering conclusions follow:

    1. Matching is prefix-based, not arbitrary fragments. Only content that matches from the very beginning can hit. Insert one changing character in the middle and everything after it degrades to a cache miss.
    2. Caches typically have a lifetime window and a capacity limit. Only high-frequency, stable prefixes have reuse value.
    3. Whether a request hits depends on request content, not business semantics, so it can be controlled deliberately in code.

    3. Cost Model: Do the Math Before You Act

    Assume a lightweight model with input unit price P_in, cache-hit input price of 0.2 × P_in, and output unit price P_out. For a request with T_in input tokens and T_out output tokens, where a cacheable prefix accounts for a fraction r of the input, the cost per request is:

    1. Cost = T_in × P_in × (1 - r) + T_in × P_in × 0.2 × r + T_out × P_out
    2. = T_in × P_in × (1 - 0.8r) + T_out × P_out

    This shows two things. Input cost falls linearly with r, and as r approaches 1, input spend can be compressed to 20% of its original level. But if T_out × P_out dominates, the overall gain from input optimization hits a ceiling. So before making changes, run a cost attribution on real traffic to determine whether the bottleneck is input or output.

    A reusable estimation script:

    1. def estimate_cost(t_in, t_out, r, p_in, p_out, hit_ratio=0.2):
    2. """r: share of input that is a cacheable prefix; hit_ratio: cache-hit price relative to full price"""
    3. input_cost = t_in * p_in * ((1 - r) + hit_ratio * r)
    4. return input_cost + t_out * p_out
    5. # Example: long system prompt + short user question
    6. print(estimate_cost(4000, 200, r=0.9, p_in=1e-6, p_out=2e-6))

    4. Implementation: Structured Methods to Raise Hit Rates

    4.1 Layer the Prompt: Put Stable Content First

    Split the prompt into a stable layer, a semi-stable layer, and a volatile layer, and never reorder them:

    1. [System role and compliance constraints] # Almost never changes, longest, goes first
    2. [Domain knowledge and few-shot examples] # Updated by version
    3. [Conversation history summary] # Changes per session
    4. [Current user input] # Different every time, goes last

    If volatile fields such as timestamps, random IDs, or user nicknames are placed at the top, the entire prefix is invalidated. This is the most common hit-rate killer in practice.

    4.2 Keep the Prefix Consistent Within a Session

    Multi-turn conversations should reuse the same history prefix. Maintain context by appending rather than rewriting. When compressing history into a summary, restructure it once at the session boundary instead of regenerating the wording every turn.

    4.3 Batching and Concurrency Strategy

    Under high concurrency, scheduling requests with the same prefix together increases the chance of reuse within the cache window. Offline batch jobs are especially well suited to a unified template, pushing r close to 1.

    4.4 Build Observability

    Without a metrics loop, optimization cannot be verified:

    • Hit rate: cache-hit input tokens / total input tokens.
    • Cost attribution: the respective share of input, output, and cache-hit charges.
    • Prefix fingerprint: hash templates and monitor hit-rate drops caused by template changes.
    • Alerts: notify the owner when the hit rate drops beyond a threshold compared with the previous period.

    5. Common Pitfalls and Risks

    • Pitfall 1: assuming the discount cuts the total bill by 80%. It applies only to the cache-hit portion and must be converted using the formula.
    • Pitfall 2: chasing extremely long prefixes. An overly long prefix crowds the context window, and after a template update the cache-miss cost is actually higher.
    • Pitfall 3: putting sensitive information in a cacheable prefix. Cache reuse means content is retained on the server for a period, so personal information and keys belong in the volatile layer, following the principle of least necessity.
    • Regional differences: this adjustment covers only a specific region. For cross-region deployments, calculate costs separately rather than extrapolating global cost from a single price list.

    6. Action Checklist

    1. Run an input/output cost attribution on real traffic.
    2. Restructure prompts into three layers and strip out volatile fields.
    3. Ship hit-rate and cost dashboards with drop alerts.
    4. Use unified templates for offline jobs and keep prefixes stable for online sessions.
    5. Establish template version control and regression-test hit rate and business results after changes.

    Following this path can usually compress input-side spend considerably without changing model capability or business metrics. The “reusable prefix” design also applies to any token-billed LLM service and carries over across platforms.