LLM Prompt Caching and Price Cuts: The Engineering Logic Behind Lower Costs

    This article explains why recent price reductions for cached LLM input tokens reflect a shift in cost structure rather than a marketing promotion. It covers how agent workloads naturally suit exact prefix caching, how KV cache size and lifetime affect how many reusable prefixes can coexist, and three practical actions developers can take: prefix layering and ordering, prefix versioning, and hit-rate observability. It also outlines common mistakes that reduce cache efficiency.

    1. The Real Story: A Price Cut Is a Cost-Structure Shift, Not a Discount Campaign

    A recent change in some LLM services lowered the billing rate for “input cache hits” to one-tenth of the launch price across all model tiers, stacking it on top of existing discounts to create what is effectively a “discount on a discount.” Treating this as a pure marketing move misses the real engineering signal: the cost structure of inference is being reshaped by agent workloads.

    Start with the general model for input billing. The input of a request usually has two parts: the portion that misses the cache is billed at the standard input rate, while the portion that hits the cache is billed at a significantly lower rate. Providers can push the hit price this low because the cached portion skips repeated computation and GPU memory reads and writes, sharply reducing marginal cost. The precondition for the price cut is therefore not “user luck” but a workload that is inherently highly cacheable.

    2. Why Agent Workloads Are a Natural Fit for Exact Prefix Caching

    Agent-style requests share a stable trait: a long, unchanged prefix and a short, highly variable suffix.

    A typical request can be abstracted as:

    1. [ system prompt ][ tool schema ][ repo context ][ memory ][ session summary ] [ observation / task / run id ]
    2. └──────────────────── stable prefix (cacheable) ────────────────────┘ └──── variable suffix (not cacheable) ────┘

    The stable prefix includes system instructions, structured descriptions of tools and functions, code repository context, long-term memory, and session summaries. Only the latest observation, the current task description, and the run identifier change each turn. Because caching typically uses exact prefix matching as the hit condition, this structure makes the hit rate climb quickly as the session progresses: the first turn establishes the cache, and every subsequent turn reuses the same prefix.

    A simplified hit-detection logic looks like this:

    1. def cache_hit(prefix_tokens, cached_prefix):
    2. # Exact prefix caching: compare segment by segment from the start, stop at the first difference
    3. n = min(len(prefix_tokens), len(cached_prefix))
    4. for i in range(n):
    5. if prefix_tokens[i] != cached_prefix[i]:
    6. return i # matched length
    7. return n

    The key is “stop at the first difference.” Any tiny change anywhere in the prefix invalidates everything after it. Stability is not a bonus; it is the only source of hit rate.

    3. The Overlooked Half: KV Cache Footprint

    The hit rate only determines how much computation you can save. The size and lifetime of the key-value cache (KV Cache) determine how many reusable prefixes can be held at the same time. Caching consumes GPU memory or high-speed storage, and eviction occurs when capacity is limited. If a single prefix has a large KV cache footprint, fewer sessions can coexist, and the hit rate gets undercut by the capacity bottleneck.

    Four factors are widely recognized as influential: model size and number of layers, number of attention heads and head dimension, context length, and the storage precision of the KV cache. The first three are determined by model specifications. The fourth is the engineering-side optimization space: lowering KV cache storage precision within an acceptable accuracy range can significantly increase the number of prefixes that fit and the reuse window. This is the other half of why an “across-the-board price cut” is viable—each unit of capacity can serve more hits.

    4. Turning the Price Cut Into a Bill: Three Actionable Steps

    First, layer and order the prefix. Put stable content first and volatile content last, ordered from lowest to highest change frequency; place run identifiers, timestamps, and random numbers at the very end so they do not pollute the prefix.

    1. [ versioned system instructions ][ tool descriptions ][ repo and rules ][ long-term memory ][ session summary ][ current-turn observation ][ run id ]

    Second, version the prefix and roll out gradually. Once the system prompt or tool descriptions change, treat them as a new prefix and version them explicitly, so a “one-word change invalidates the whole segment” problem can be located rather than being a mystery.

    Third, make the hit rate observable. Collect at least four metrics—matched length, hit ratio, average reuse turns, and cache eviction count—and feed them into monitoring, alerting, and logging to build a cost dashboard.

    5. Common Pitfalls

    • Mistaking “long context” for “high hit rate”: what truly drives hits is whether the prefix is byte-for-byte stable.
    • Inserting dynamic content mid-session: writing the current time into the system prompt, for example, invalidates the entire prefix.
    • Optimizing only unit price while ignoring capacity: when the KV cache footprint is too large, eviction eats up the hit-rate gains.
    • Ignoring multi-tenant isolation: mixing tool descriptions from different workloads under the same prefix both lowers the hit rate and creates cross-contamination risk.

    6. Conclusion

    The technical meaning of this price cut is clear: when a workload has a long, stable prefix and a controllable KV cache footprint, the marginal cost of the cached portion is already low, so price naturally regresses toward cost. For developers, the transferable methodology is a three-part toolkit: prefix stabilization, cache capacity optimization, and hit-rate observability. With model services on platforms such as Baidu AI Cloud working alongside general capabilities like container platforms, object storage, and monitoring and alerting, teams can turn cache hit rate into a continuously optimizable engineering metric rather than leaving it to luck.