Understanding LLM API Cache Pricing: Why a Price Increase Isn't a Uniform Hike
This article breaks down the cache-based billing logic behind a recent LLM API price adjustment, showing why the same model can cost less for some workloads and more for others. It explains the prefill/decode disaggregated inference architecture that makes prefix caching possible, provides formulas and two scenarios for calculating your real effective unit cost, and lists practical optimization tactics such as prefix structuring, reducing output share, stabilizing retrieved context, batching, and tracking unit-cost metrics.
1. The Trigger: A Pricing Update That Looks Like a Blanket Increase
When a next-generation model from an AI coding tool was announced, community discussion quickly zeroed in on a side-by-side comparison. On the output side, the previous generation was about CNY 27 per million tokens; the new one is CNY 100. On the input side, cache misses rose from CNY 6.5 to CNY 20, while cache hits rose from CNY 1.1 to CNY 2. At first glance, everything went up. Break the three tiers apart, however, and the conclusion changes completely.
Start with the multipliers:
| Billing tier | Previous gen (CNY / M tokens) | New gen (CNY / M tokens) | Multiplier |
|---|---|---|---|
| Output | 27 | 100 | ~3.7x |
| Input, cache miss | 6.5 | 20 | ~3.1x |
| Input, cache hit | 1.1 | 2 | ~1.8x |
What matters is not the absolute multiplier but that the ratios between tiers were deliberately widened:
- Miss input / hit input: from about 6x to 10x;
- Output / hit input: from about 25x to 50x.
The pricing structure shifted from a gentle staircase to a steep lever. The cache-hit tier saw the smallest increase, while the output tier saw the sharpest one. In effect, the vendor is using price signals to steer traffic structure: whoever can shape requests into “high reuse, low output share” gets an effective unit price close to a discount, while everyone else pays close to list price or a premium.
2. Why Vendors Can Price This Way: Disaggregated Inference and Cache Reuse
This kind of pricing usually rests on an engineering prerequisite: a high cache hit rate on the inference side. A common industry approach is a disaggregated inference architecture, which separates two phases:
- Prefill phase: compute-intensive, processes long prompts, and produces reusable intermediate state (the KV cache);
- Decode phase: memory-access-intensive, generates tokens one by one, and is latency-sensitive.
Once separated, the intermediate state from prefill can be persisted and reused across requests. When multiple requests share the same prefix (system prompt, tool definitions, repository context, few-shot examples), any request after the second only pays for the “new portion,” while the matched portion is billed at a very low price. When a technical team reports a hit rate above 90% for coding scenarios, the price lever above makes complete sense.
Note that this is a general industry technical approach, not a proprietary feature of any single vendor. The actual hit rate depends on the workload, not on marketing claims.
3. Two Variables Determine Your Real Bill
Let the input-to-output ratio be R (input tokens / output tokens) and the cache hit rate be h. Then:
Effective input unit price = P_hit × h + P_miss × (1 - h)Blended unit cost = (R × effective input unit price + P_out) / (R + 1)
Scenario A: Enterprise long-context agent
Parameters: R ≈ 20, h ≈ 0.9.
Input side = 2×0.9 + 20×0.1 = 3.8Blended = (20×3.8 + 100) / 21 ≈ CNY 8.4 / M tokens
Scenario B: Low-frequency individual developer, different prompt every time
Parameters: R ≈ 5, h ≈ 0.2.
Input side = 2×0.2 + 20×0.8 = 16.4Blended = (5×16.4 + 100) / 6 ≈ CNY 30.3 / M tokens
Same model, same price table, yet the two blended unit costs differ by roughly 3.6x. The conclusion is not dramatic: this adjustment is a discount for high-reuse customers and a price increase for low-reuse customers. To know which side you are on, measure just two metrics: prefix reuse rate and output share.
4. Actionable Cost Optimization Tactics
1. Fix the prefix and layer your prompts
Putting stable content first and volatile content last is the most effective way to raise the hit rate. A suggested layering:
[Stable layer] Role definition, safety constraints, output format spec, tool schema[Semi-stable layer] Repository structure notes, coding conventions, a few examples[Volatile layer] Current user question, latest retrieved snippets, timestamps
Once the order is scrambled (for example, putting a timestamp at the very front), the entire prefix cache is invalidated.
2. Cut the output share
The output price is 50x the hit-input price, so “generate less” is worth more than “input less”: have the model return patches instead of whole files, return structured fragments instead of long explanations, and split long-form generation into small, verifiable steps.
3. Govern the stability of retrieved snippets
Dynamically concatenated retrieval results keep punching holes in the cache. Normalize snippets (sort them, strip timestamps, use a fixed template), or move them to the tail of the volatile layer.
4. Batch and go asynchronous
For offline tasks, use batch endpoints and off-peak scheduling, separating latency-insensitive workloads from online interaction. This often stacks with additional discounts.
5. Build a unit-cost dashboard
Track at least four metrics: hit rate, input-output ratio, average output length, and cost per task. Looking at the total bill alone cannot localize the problem.
def unit_cost(inp, out, p_hit, p_miss, p_out, hit_ratio):eff_in = p_hit * hit_ratio + p_miss * (1 - hit_ratio)return (inp * eff_in + out * p_out) / (inp + out)
5. Neutral Guidance on Selection and Migration
Faced with a new price table, there is no need to rush into migration or resist it. Take three steps: first, replay real traffic to measure your own hit rate and input-output ratio; second, convert those into a blended unit price with the formula above and compare it on the same basis with other options you are using; finally, do engineering work on the item with the largest gap. If you use model services from Baidu AI Cloud, the same recommendation applies: use “hit rate + input-output ratio” as the evaluation baseline, and continuously observe unit-cost changes with monitoring, alerting, and logging services.
6. Conclusion
The essence of this pricing round is not a blanket increase but a billing structure moving from smooth to levered: the vendor makes cost differences explicit as price differences and hands optimization responsibility back to the caller. For developers, the cache hit rate has been upgraded from a performance metric to a financial one — it directly determines whether you get the discount price or pay a premium.
