The Cost Logic Behind LLM API Price Hikes and How to Optimize It
This article breaks down large language model API pricing into three tiers—uncached input, cached input, and output—and shows how the real cost per token is a weighted result of those rates together with your workload's cache hit rate and input-to-output ratio. It explains why the same model can differ severalfold in cost-efficiency across workloads, why high cache hit rates above 90% are achievable with disaggregated inference, how agent workloads change the cost structure, and lists practical engineering steps to keep spending under control.
When a large model service raises prices severalfold, many teams’ first reaction is that it has become unaffordable. But if you break the list price apart, the real cost is not a single number. It is a weighted result determined by three unit rates—uncached input, cached input, and output—combined with your workload’s context reuse rate and input-to-output ratio. This article reconstructs that cost model, explains why the same model can offer severalfold different cost-efficiency on different workloads, and lays out actionable ways to cut costs.
1. Split the List Price into Three Tiers, Not One Number
Billing for mainstream large model services is usually split into three tiers: uncached input, cached input, and output. Comparing a recent-generation model with the previous generation’s coding-focused model, for example, the output rate rose from about RMB 27 to RMB 100 per million tokens, close to 4x; the input side went from RMB 6.5 / RMB 1.1 to RMB 20 / RMB 2, roughly 3x.
What deserves more attention than the multipliers is the change in the ratio structure:
- The ratio of uncached input to cached input widened from about 6x to 10x;
- The ratio of output to cached input widened from about 25x to 50x;
- The cached-input tier saw the mildest increase, while the output tier rose the most sharply.
The signal from these ratios is clear: pricing is shifting from “charging an average rate per token” to “charging differently by degree of reuse.” Whoever can reuse a prefix over the long term enjoys an implicit near-discount price; whoever sends a brand-new context on every request pays the full price or even a premium.
2. The Real Unit Cost Can Be Calculated with Weights
Let the input-to-output ratio be r (input tokens divided by output tokens) and the cache hit rate be h. Then:
effective input rate = cached rate × h + uncached rate × (1 - h)blended unit cost = (r × effective input rate + output rate) / (r + 1)
Scenario A: an enterprise-grade long-context coding agent, r ≈ 20, h ≈ 0.9.
Effective input rate ≈ 2 × 0.9 + 20 × 0.1 = RMB 3.8; blended cost ≈ (20 × 3.8 + 100) / 21 ≈ RMB 8.4 per million tokens.
Scenario B: a light individual developer, r ≈ 5, h ≈ 0.2.
Effective input rate ≈ 2 × 0.2 + 20 × 0.8 = RMB 16.4; blended cost ≈ (5 × 16.4 + 100) / 6 ≈ RMB 30.3 per million tokens.
On the same model, the former’s unit cost is roughly one-third to one-quarter of the latter’s. The conclusion is not “prices went up” but “pricing got tiered.” In engineering terms, only three variables are worth optimizing: the hit rate h, the input-to-output ratio r, and the compute efficiency behind each token.
3. Why a Hit Rate Above 90% Is Achievable
A high hit rate is not marketing talk but an engineering outcome of disaggregated inference architecture. Its core is splitting two phases apart:
- The prefill phase is compute-intensive and produces a reusable KV Cache;
- The decode phase is memory-access-intensive and generates tokens one by one.
Centralizing the KV Cache into an independent cache pool for unified management, together with prefix-tree matching and request scheduling, lets requests sharing the same system prompt, the same tool descriptions, or the same long-document prefix reuse computed results directly. Publicly reported industry practice shows that in long-context agent workloads with a fixed prefix, a hit rate above 90% is achievable—provided prefixes are highly consistent across requests.
4. Why Agent Workloads Change the Cost Structure Completely
In the chat era, a single interaction involved only tens to a few thousand tokens, with low price sensitivity. The agent era is entirely different: a single task may involve thousands of tool-call steps, accumulate hundreds of thousands of tokens, or run hundreds of agents in parallel continuously for days.
Three characteristics of this kind of workload amplify cost:
- Context grows linearly or even superlinearly, and the memory footprint and storage overhead of the KV Cache rise accordingly;
- The decode phase is constrained by memory bandwidth, and bandwidth consumption becomes significant under long contexts;
- Although sparse architectures keep activated parameters under control, the weights that stay resident in memory, the communication overhead of expert routing, and operator optimization under hybrid attention mechanisms all require real compute investment.
So running long tasks at the old prices loses money on the inference side; the price increase is an inevitable move to make the cost structure explicit.
5. A Checklist of Cost-Controlled Engineering Practices
- Stable prefix: keep the system prompt, tool schema, and few-shot examples fixed at the front, put variable content at the end, and maximize the matched prefix length.
- Layered context: put static knowledge in the cache layer and dynamic state at the tail, avoiding mid-context insertions that invalidate the prefix.
- Compress input: run retrieval and summarization on long documents first, and feed only the necessary fragments into the context to directly lower r.
- Control output: use structured output, limit chain-of-thought length, and avoid repetitive generation; output has the highest unit rate, so the payoff is the most direct.
- Tiered routing: send simple requests to small models or rules, and reserve the flagship model for complex requests.
- Observability: use monitoring, alerting, and logging services to track token consumption, hit rate, and per-task cost by business dimension, turning cost into a regression-testable metric.
- Elastic capacity: use container platforms and message queues for task queuing and concurrency control to avoid peak-time waste.
6. Conclusion
Prices rising severalfold is essentially the industry moving from “subsidized low prices” to “billing by real resource consumption.” For developers, the right response is not to switch models but to govern the hit rate, the input-to-output ratio, and output length as first-class performance metrics. Get these three right, and unit business cost can hold steady or even fall despite a higher list price; fail to do so, and any low price will break down under high-consumption workloads.
