The Cost Logic Behind the LLM API Price War
A practical breakdown of how LLM API pricing actually works, covering asymmetric input/output rates, prompt caching discounts, model tiering, a cost formula with worked examples, and architecture patterns for reducing spend without sacrificing quality.
1. The Phenomenon: Why the Same Generation of Models Shows a Multiple-Fold Price Gap
Over the past year, LLM API price lists have started to look like a tiered menu. A single vendor often offers flagship, balanced, and lightweight tiers at the same time, with price gaps of more than five times. Across vendors, even when parameter counts and capability positioning are similar, the price per million tokens can still differ by several times. If you only look at the unit price ranking, it is easy to conclude that “one vendor is the cheapest,” but that conclusion rarely holds up in engineering practice.
A real bill is determined by four variables together: unit price, token consumption structure, cache hit rate, and the number of retries and multi-turn calls required to meet business targets. Ignore the last three, and any price comparison is just a number on paper.
2. Breaking Down the Pricing Model: Three Undervalued Variables
2.1 Asymmetric Pricing for Input and Output
The common industry practice is to price output tokens significantly higher than input tokens, typically by a factor of three to six. The reason is that the autoregressive decoding stage cannot be sufficiently parallelized, so compute utilization is naturally lower than in the prefill stage. This means that a summarization task with “long input, short output” and a generation task with “short input, long output” can differ in cost by several times, even when the total token count is the same.
2.2 Cache Hit Discounts
Mainstream platforms generally offer context caching: when the request prefix matches previous requests, that portion of the input is billed at a significant discount. In an illustrative price structure, regular input is on the order of 1.25 USD per million tokens, while a cache hit can drop to around 0.15 USD, a discount close to 90%. For scenarios with a fixed system prompt and reused knowledge base documents, this is the single largest source of cost reduction.
2.3 The Model Tier Matrix
The lightweight tier typically delivers “good enough” capability at one-tenth to one-fifth of the flagship input price. The correct engineering approach is not to pick one or the other, but to build a routing layer that splits traffic by task difficulty.
3. Cost Estimation: Turning a Price List into a Computable Formula
Let the input tokens be $I$, the output tokens be $O$, the cache hit ratio be $h$, the input unit price be $p_i$, the cached input unit price be $p_c$, and the output unit price be $p_o$. The cost of a single call is:
Cost = I * (h * p_c + (1 - h) * p_i) + O * p_o
Take three typical price points (per million tokens, input/output): high tier 5 / 30, mid tier 2.5 / 15, low tier 1 / 6. Assume a task with 8,000 input tokens and 500 output tokens:
- Without caching, the high tier costs about 0.055 USD and the low tier about 0.011 USD.
- If 6,000 of the 8,000 tokens are cacheable system prompt and fixed documents, with a 90% hit discount, the low tier drops to about 0.0035 USD.
Conclusion: the gains from caching are often larger than the gains from repeatedly weighing one tier against another.
4. Four Cost-Reduction Techniques at the Architecture Level
- Fix the prompt prefix. Place system instructions, tool descriptions, and few-shot examples at the very front of the request and keep their order unchanged, maximizing prefix cache hits.
- Semantic caching. Build a vector index for high-frequency similar questions and return the result directly on a hit, avoiding repeated inference.
- Cascaded calls. Use the lightweight tier first to determine intent and difficulty, and escalate only high-difficulty requests to the flagship tier.
- Output constraints. Use structured output and length limits to suppress redundant generation, directly compressing the most expensive output tokens.
Illustrative routing logic:
def route(prompt):if is_simple(prompt): # classification, extraction, rewritingreturn light_model(prompt)if needs_reasoning(prompt): # multi-step reasoning, code generationreturn flagship_model(prompt)return balanced_model(prompt)
5. Engineering Support: Making Cost Observable
Cost reduction starts with measurability. It is recommended to collect input/output tokens per call, cache hit flags, time to first token, and retry counts, then build a dashboard through logging services and monitoring alerts, with budget thresholds and circuit-breaking policies set per business line. For evaluation, build an offline regression set: any tier switch must verify accuracy and hallucination rates, so you avoid “saving money while losing quality.”
6. Conclusion
The ordering of price lists will keep changing, but the cost structure is stable: asymmetric pricing drives task selection, caching determines reuse gains, and tiering determines the overall average price. General-purpose model services from vendors such as Baidu AI Cloud, together with supporting data, storage, and monitoring capabilities, can serve as the infrastructure for putting this framework into practice. For developers, what really needs to be built is not a memory of any single price list, but a cost evaluation and scheduling system that can evolve sustainably.
