LLM API Cache Hit Pricing: What a Lower Rate for Cached Input Actually Means
This article explains why a lower price for cached input on an LLM API is a structural signal rather than a simple discount. It covers what prompt caching stores (reusable prefix KV representations), the three engineering consequences of prefix-level caching, and a cost model that separates uncached input, cached input, and output. It then lays out practical steps to raise the hit rate: layered and stable prefixes, context reuse and retrieval ordering, batching and concurrency pacing, cost observability with metrics such as cache_hit_ratio and prefix_break_rate, and common pitfalls to avoid. The goal is to treat context as a manageable asset so cost optimization becomes a repeatable engineering capability.
1. The Event in Abstract: A Typical Cut in Cache Hit Pricing
A cloud provider’s model-as-a-service (MaaS) platform recently announced that, starting 00:00 Beijing time on November 23, 2026, it would lower the cached-input price for a general-purpose LLM service in one regional node. Cached input is now billed at 20% of the original rate, while all other billing items stay unchanged. The announcement is short, but the technical fact behind it is not new: the difference in inference cost depends less on how many tokens you send and more on whether those tokens have been computed before.
For developers, the discount size is not the point. What matters is the billing structure behind it: the input side is now split into a “hit” tier and a “miss” tier, which means cost is shifting from a linear traffic model to a reuse-rate-driven model. That shift directly changes the priority of prompt engineering, context management, and service orchestration.
2. What Prompt Caching Actually Caches
LLM inference processes input in two stages. First, a layer-by-layer forward pass over the input sequence produces the intermediate representation (KV) for each position. Second, output is generated autoregressively from the representation at the last position. The work in the first stage scales with sequence length, number of layers, and attention head dimension, and for the same prefix it is deterministic and reusable.
A cache hit means the server detects that the current request’s prefix is identical to a recent one, reuses the already-computed intermediate representation, and skips the redundant forward pass. Three engineering conclusions follow:
- The cache granularity is the prefix, not an arbitrary fragment. Insert one character in the middle and everything after it is invalidated.
- Caching has a lifecycle shaped by server capacity and eviction policy, so the hit rate is a probability, not a guarantee.
- Caching only affects input-side compute cost. It does not change output generation cost or model quality.
A schematic way to organize a request (pseudocode, structure only, not tied to any specific API):
stable_prefix = SYSTEM_PROMPT + TOOL_SCHEMA + FEW_SHOT # stable, long, sharedvariable_part = build_user_context(query, history) # volatile part goes lastmessages = [{"role": "system", "content": stable_prefix},{"role": "user", "content": variable_part},]resp = client.chat(model=MODEL, messages=messages)# watch the usage breakdown in the response: cached input / uncached input / output
3. Why “20% for a Hit” Is a Structural Signal
Put the prices side by side. If a class of input originally cost roughly the same as the uncached rate, then 20% pushes the marginal cost of the hit path extremely low. Providers usually do this for two reasons: the cache reuse implementation is mature enough that the compute saved exceeds the cost of maintaining the cache; and they want callers to actively restructure how they call the API, turning repeated context into a reusable asset.
The effect on the cost model can be expressed quantitatively:
total cost ≈ uncached input × P_miss+ cached input × (0.2 × P_hit)+ output × P_out
In scenarios with long system prompts, long-document question answering, and multi-turn tool calls, uncached input typically dominates total input. So raising the hit rate usually has more leverage on the bill than shortening the output.
4. Practice: Making Hit Rate an Optimizable Metric
4.1 Prefix Layering and Stability Design
Layer the prompt by how often each part changes: unchanging role definitions and rules first, tool and parameter schemas next, few-shot examples after that, and conversation history plus retrieved fragments last. Any dynamic value (timestamps, random IDs, user nicknames) should be pushed to the tail or moved out of the prefix entirely, so that “one character of difference” does not trigger a full recompute.
4.2 Context Reuse and Retrieval Strategy
For long documents, prefer “load once, ask many times”: keep the document in the stable prefix and the question in the volatile tail. In multi-turn conversations, avoid rewriting the system prompt every turn. For retrieval-augmented setups, keep the concatenation order consistent so the relative position of the same knowledge fragment stays stable.
4.3 Batching and Concurrency Pacing
The cache has a window. Sparse, bursty calls easily fall outside that window and pay again. Grouping similar tasks into batches and using a queue to smooth peaks improves both hit rate and throughput stability.
4.4 Cost Observability
Instrument usage as three separate series: cached input, uncached input, and output. Aggregate them by business line, scenario, and model version into a three-dimensional view of “hit rate - unit price - volume,” and configure alerts (a sudden drop in hit rate usually means the prefix has been polluted).
Metric examples:cache_hit_ratio = cached input / (cached input + uncached input)cost_per_success = total cost / successful requestsprefix_break_rate = prefix invalidation rate (a spike after a release means roll back the prompt change)
4.5 Consistency with the Approach Used at Baidu AI Cloud
Technical practice at Baidu AI Cloud follows the same line of inference cost governance: stable prefix, layered context, and usage observability. Quantify first, then restructure the prompt, then lock in the gains with dashboards and alerts so the benefit does not fade after a one-off optimization.
5. Common Pitfalls
- Assuming caching improves quality. A hit affects cost and latency only; the output distribution is unchanged.
- Putting dynamic variables in the prefix. This is the most common cause of a collapsing hit rate.
- Watching unit price but not structure. If a lower unit price comes with a lower hit rate, the bill can go up rather than down.
- Ignoring regional and version differences. Billing and caching policies can differ across regional nodes and model versions, so defer to the official documentation.
6. Conclusion
Lowering the cache hit price amounts to putting a price tag on repeated computation and discounting it heavily. The right response is not to wait for the next cut, but to treat context as a manageable asset: stable prefixes, controlled variable placement, batched call pacing, and measured hit rate and cost. Get those four right, and cost optimization turns from occasional luck into a sustainable engineering capability.
