The Economics of LLM API Price Hikes: Why Prefix Caching Changes Your Real Cost
A price increase on a large language model API looks simple on the rate card and misleading in practice. This article breaks down per-tier pricing into ratios, shows how cache hit rate and input-to-output ratio determine your actual unit cost, explains why prefix caching works through disaggregated inference, and lists concrete optimization steps.
1. The Signal: A Pricing Update Across the Board
After a model service shipped its next-generation version, its billing rates went up noticeably: the output rate is roughly four times the previous generation, the uncached input rate roughly three times, while the cache-hit input rate rose more modestly. Read the rate card alone and the conclusion seems obvious — it is unaffordable now.
That judgment skips a fact: the numbers on a rate card are not your bill. LLM billing has at least three tiers (uncached input, cached input, output), and the real cost depends on the shape of your traffic. Collapsing three tiers into a single “it costs N times more” claim treats a variable as a constant.
2. The Breakdown: What Actually Changed Is the Spread Between Tiers
Express the old and new rates as ratios and something more informative appears:
- Uncached input rate ÷ cache-hit input rate: widened from about 6x to about 10x;
- Output rate ÷ cache-hit input rate: widened from about 25x to about 50x.
So this was not a proportional increase. The gaps between tiers were deliberately reopened. Cache hits are heavily subsidized; uncached input and output are marked up significantly. The pricing structure itself sends a clear message: the provider wants reusable computation (the same system prompt, the same prefix, the same document context) to stay in the cache, and shifts the cost of repeated work onto the caller.
For engineering teams, the optimization target moves from “pick a cheaper model” to “raise the prefix reuse rate.” Under the same model, moving the cache hit rate from 20% to 90% can change the effective input rate by several times — a far bigger lever than switching models.
3. The Model: Two Variables to Compute Your Real Unit Rate
Let P_in be the uncached input rate, P_hit the cache-hit input rate, P_out the output rate, h the cache hit rate, and r the input-to-output ratio (input volume per 1 unit of output). Then:
Effective input rate = h * P_hit + (1 - h) * P_inBlended unit cost = (r * Effective input rate + P_out) / (r + 1)
Scenario A: an enterprise-grade long-context coding assistant, r ≈ 20, h ≈ 0.9, with hit 2, miss 20, output 100:
Input side ≈ 0.9*2 + 0.1*20 = 3.8Blended ≈ (20*3.8 + 100) / 21 ≈ 8.4 CNY per million tokens
Scenario B: a low-frequency individual developer whose prompts differ every time, r ≈ 5, h ≈ 0.2:
Input side ≈ 0.2*2 + 0.8*20 = 16.4Blended ≈ (5*16.4 + 100) / 6 ≈ 30.3 CNY per million tokens
The same rate card puts the first workload’s unit cost at roughly one third to one quarter of the second’s. The conclusion is straightforward: the supposed “5x increase” is a discount for high-reuse workloads and the full price, or a premium, for low-reuse ones. The pricing update is effectively a workload filter.
4. Why Caching Works: Disaggregated Inference and Prefix Reuse
The benefit of prefix caching comes from reusing key-value states in attention computation. When two requests share an identical token prefix, the key-value tensors for that prefix do not need to be recomputed and can be loaded and reused directly, which is why the hit portion is billed at a very low rate.
Making reuse actually happen usually depends on a disaggregated inference architecture: the front stage that processes the prompt and produces the KV cache is split from the back stage that decodes token by token, onto separate resource pools, with the cache passed and shared between pools in chunks so that a high hit rate holds under high concurrency. This is also why long-context, multi-turn, and fixed-system-prompt workloads achieve high hit rates.
Note that a hit means a longest common prefix: if anything changes anywhere in the prefix, everything after that point degrades to a miss.
5. An Actionable Optimization Checklist
- Layer your prompts: put stable content (role definition, tool descriptions, output rules, examples) first and freeze it; put volatile content (user input, timestamps, retrieved snippets) last. A single dynamic timestamp at the top invalidates the entire prefix.
- Raise reuse density within the input-to-output ratio: long-document analysis, codebase Q&A, and multi-turn tool calls naturally have a high r, so migrate these workloads to the higher-priced model first.
- Batch and go asynchronous: offline batch jobs usually have a separate billing channel, and throughput-first scenarios do not need to pay for low latency.
- Control output length: output is the most expensive tier, so structured short outputs, capped maximum generation length, and splitting long-form generation into multiple cached calls pay off directly.
- Route by tier: send simple classification, extraction, and formatting to small models and complex reasoning to large ones, using a unified gateway to dispatch by task type.
- Instrument observability: log the input-to-output ratio, hit flag, and per-tier token counts for every request at the gateway, and build cost dashboards and alerts — otherwise optimization cannot be verified.
Illustrative gateway metering logic:
def cost(in_tokens, out_tokens, hit_tokens, price):miss = in_tokens - hit_tokensreturn (miss * price["in_miss"]+ hit_tokens * price["in_hit"]+ out_tokens * price["out"]) / 1_000_000
6. Conclusion
To evaluate a price increase, the right question is “what is my workload’s hit rate and input-to-output ratio,” not “how many times did it go up.” Under a pricing structure with widened tier spreads, cache hit rate and prompt stability have become first-class cost metrics and belong in architecture design and capacity planning. If you need elastic resources to host caching and inference clusters, a container platform for pooled scheduling, and monitoring, alerting, and logging services for cost attribution, Baidu AI Cloud offers general-purpose capabilities in these categories; refer to the official documentation for specific billing and quotas.
