The Economics of LLM API Price Hikes: Why Prefix Caching Changes the Math
A new pricing tier for a large language model API looks like a steep increase on paper, but the cached-input tier tells a different story. This article breaks down the ratios between input, cached-input, and output prices, explains why prefix caching works in disaggregated inference serving, and provides a unified cost model that blends hit rate and input-to-output ratio into a single per-token figure. It also lists practical ways to cut spend, from prefix stability and context layering to output budget control and cost observability.
1. The Trigger: A Pricing Update That Looks Like an Across-the-Board Increase
A next-generation model from an AI coding tool provider published new billing rates. Compared with the previous generation, the output price rose to nearly four times the old level, the uncached input price rose by roughly three times, and the cache-hit tier increased only modestly. Read at face value, this is a straightforward price hike. Once the caching mechanism is factored in, the conclusion changes completely.
Start with the ratios between tiers rather than absolute prices, since ratios carry more information:
| Ratio | Previous generation | New generation | Change |
|---|---|---|---|
| Uncached input / cached input | ~6x | ~10x | Wider |
| Output / cached input | ~25x | ~50x | Wider |
| Output / uncached input | ~4x | ~5x | Roughly flat |
The table shows the vendor did not raise every tier by the same proportion. Instead, it redistributed the price gaps between tiers. The cache-hit tier was deliberately kept low, while the uncached and output tiers absorbed most of the increase. This is a typical price-structure redesign: the list price filters for high-reuse workloads, and the low hit price rewards them.
2. Technical Prerequisite: Why Prefix Caching Works
Understanding this pricing requires understanding where cache hits come from. Mainstream inference services generally adopt a disaggregated deployment: the prefill stage of a request and the decode stage are split across separate resource pools. Prefill is compute-intensive, decode is memory-bandwidth-intensive, and scheduling them independently improves overall utilization significantly. The biggest waste in prefill is recomputing an identical context prefix.
In engineering practice, requests are hashed block by block (for example, a page every fixed number of tokens) and compared block by block. On a hit, the corresponding key-value tensors are loaded directly from cache, and only the uncached portion is recomputed. Hit rate therefore depends almost entirely on prefix overlap between requests. Publicly documented engineering practice shows that in coding workloads with long contexts and a fixed system prompt, hit rates above 90% are achievable; in scattered calls where the prompt changes every time, hit rates may be only 10-20%.
This explains a key fact: a cache hit is not a vendor’s favor but a direct mapping of workload characteristics. Pricing has monetized that mapping.
3. A Unified Cost Model
Let the uncached input price be $P{in}$, the cached input price be $P{hit}$, the output price be $P_{out}$, the hit rate be $h$, and the input-to-output ratio be $r$ (r units of input per 1 unit of output). The blended cost per million tokens is:
effective_input = h * P_hit + (1 - h) * P_inblended_cost = (r * effective_input + P_out) / (r + 1)
Plugging in both generations’ prices (unit: CNY per million tokens; new generation 20 / 2 / 100, previous generation 6.5 / 1.1 / 27):
Scenario A: enterprise long-context coding agent, $r=20$, $h=0.9$
effective_input = 0.9*2 + 0.1*20 = 3.8blended = (20*3.8 + 100) / 21 ≈ 8.4
Scenario B: scattered calls with a different prompt each time, $r=5$, $h=0.2$
effective_input = 0.2*2 + 0.8*20 = 16.4blended = (5*16.4 + 100) / 6 ≈ 30.3
Under the same model, A’s unit cost is about one third of B’s. Compare the previous generation in the same scenarios: A was about 3.0 CNY, B about 15.0 CNY. In other words, A’s effective increase is close to 2.8x and B’s close to 2.0x. High-reuse customers absorbed the larger nominal increase, but because their base was low, the absolute increment stayed manageable; low-reuse customers saw a seemingly moderate increase yet lost the price-gap benefit they previously enjoyed.
Conclusion: nominal increase and actual cost change are not the same thing. Evaluating any price adjustment requires plugging in your own $h$ and $r$.
4. Practical Ways to Cut Costs
- Prefix stability governance. Put invariant content such as system prompts, tool definitions, examples, and long documents at the front in a fixed order, and never insert timestamps, random IDs, or dynamically retrieved fragments in the middle. Any single change invalidates every block after it.
- Context layering. Explicitly separate a stable layer, a semi-stable layer, and a volatile layer, and place volatile content as late as possible to shorten the invalidated tail.
- Prompt compression and retrieval substitution. Inject fragments on demand via retrieval instead of stuffing an entire corpus into the context; summarize conversation history rather than concatenating it in full.
- Batching and asynchrony. Merge requests for latency-insensitive offline tasks to raise decode-stage throughput and amortize unit cost.
- Output-side budget control. The output tier is usually the most expensive, so capping maximum generation length and avoiding verbose restatement often pays off more than optimizing input.
- Cost observability. Build per-business-line and per-endpoint dashboards for tokens and cache hit rate on top of logging services and monitoring alerts, and track $h$ as a first-class metric.
Illustrative hit-rate self-check logic:
def estimate(hit_ratio, pin, phit, pout, r):eff_in = hit_ratio * phit + (1 - hit_ratio) * pinreturn (r * eff_in + pout) / (r + 1)# Alert when hit rate drops below threshold, indicating prefix pollutionif hit_ratio < 0.7:alert("prefix cache degraded, check prompt stability")
5. Conclusion
The essence of this price adjustment is a shift from average per-token billing to differentiated billing by reuse level. For enterprise workloads that run a fixed prefix over the long term, it is effectively a structural discount; for one-off, fragmented calls, it is the original price or even a premium. The right response for developers is not to complain about the list price but to bring cache hit rate into architecture design and cost dashboards, using prefix engineering to turn the pricing rules into a cost advantage. If you need elastic compute and full-chain observability, general-purpose capabilities such as container platforms, object storage, and log monitoring from Baidu AI Cloud can be used to build your own measurement and governance setup.
