Why LLM API Prices Are Rising: The Cost Logic Behind Token Billing
A practical guide to understanding why flagship LLM API pricing is rising, how input, output, and cache pricing are structured, and how to estimate and reduce inference costs through prefix stabilization, output constraints, model routing, retrieval, and observability.
When a new generation of flagship models arrives with prices several times higher than before, output tokens priced well above input tokens, and cache hits billed at only a fraction of the standard input rate, many teams conclude that these APIs have simply become unaffordable. Look at the bill more closely, however, and the price structure follows a clear cost logic: it charges according to the real consumption of compute resources and returns the waste of repeated computation to the caller in the form of a discount. This article does not target any specific vendor’s product. Instead, it abstracts this billing pattern into a general engineering problem: how to understand pricing, how to estimate costs, and how to bring the bill down by adjusting architecture and call patterns.
1. Build the Right Mental Model for Billing
The billing items of mainstream LLM APIs generally fall into four categories, and understanding the differences between them is the prerequisite for cost control.
- Input (prompt) billing: charged by the length of the context the caller sends. The unit price is relatively low because the computation in the prefill stage can be highly parallelized.
- Output (completion) billing: charged by the tokens the model generates. The unit price is usually several times that of input. The reason is that the decode stage generates tokens serially, one at a time, and every step must read all model weights and the existing context. This is a memory-access-intensive workload, so the compute and bandwidth cost per token is far higher than in prefill.
- Cache hit billing: when the prefix of the current request is exactly identical to a recent request, the server can reuse the intermediate state that has already been computed and only compute the newly added part, so this portion is billed at a very low unit price.
- Cache write/storage billing: some schemes charge separately for the first write into the cache or for how long the cache is retained. The magnitude is usually small, but scenarios with long contexts and frequent switching need to factor it in.
This yields a practical cost formula:
Cost per request =uncached input tokens × input unit price+ cached input tokens × cache unit price+ output tokens × output unit price+ fixed add-ons (cache writes, retrieval, tool calls, etc.)
The key takeaway: a high output unit price means that “making the model say less” is the first lever for saving money; a low cache unit price means that “keeping the prefix stable” is the second lever. Combined, the two are often more effective than switching to a cheaper model.
2. Why Flagship Model Price Increases Are a Structural Trend
Understanding a price increase as nothing more than vendors chasing profit is incomplete. The scale of flagship models keeps expanding, with both total and activated parameter counts rising. Sparsification (MoE) lowers the average computation per token, but memory footprint, the memory-access overhead introduced by expert routing, and attention overhead under long contexts are all growing. At the same time, context windows are expanding from hundreds of thousands to the million-token range, which means the prefill cost of a single request can easily grow by one or two orders of magnitude.
On the supply side, the cost items include accelerator depreciation and procurement, cluster networking and parallel communication, memory capacity, the scheduling efficiency of the inference framework, and the extra cache space required to support long contexts. When call volume grows while the cost per unit of resource does not fall in step, a restructuring of prices is almost inevitable. The more rational approach, therefore, is to treat LLM calls as a production workload that requires capacity planning and cost governance, rather than an external service with a fixed unit price.
3. Cost Estimation: Do the Math Before You Call
It is worth introducing a lightweight estimation script at the coding stage to project monthly spend using real business samples:
# Illustration: estimate monthly inference cost from business samples (prices are placeholders; replace with actual quotes)def estimate_monthly_cost(samples, price, concurrency_peak=1.0):total = 0.0for s in samples:cost = (s["miss_in"] * price["in"]+ s["hit_in"] * price["cache"]+ s["out"] * price["out"])total += cost# Amplification factor from retries and queuing under peak concurrency; empirically 1.1~1.5return total * concurrency_peak
Three easily overlooked amplification factors deserve special attention when estimating. First, retries: retries triggered by timeouts or rate limiting are billed again. Second, the accumulation of historical context in multi-turn conversations: without trimming, the input length of turn N grows linearly. Third, failed requests: if generation is truncated, you still pay for the tokens already produced. Modeling these three explicitly usually narrows the budget deviation from several times over to an acceptable range.
4. Seven Cost-Reduction Techniques at the Architecture Level
- Prefix stabilization. Put invariant content such as system prompts, tool definitions, few-shot examples, and long documents at the very front of the request, keeping it byte-for-byte identical and avoiding volatile fields like timestamps or random IDs. This is the most effective way to raise the cache hit rate.
- Context layering. Separate content into a “stable layer, semi-stable layer, and volatile layer”: keep the stable layer resident in the cache, reuse the semi-stable layer per session, and put only the current question in the volatile layer.
- Output constraints. Use structured output and explicit length and format requirements to compress generation length; for tasks that do not need a reasoning chain, turn off verbose explanations. The gains are especially pronounced on models with a high output unit price.
- Model tier routing. Send simple classification, extraction, and formatting to small models or a rules engine, and escalate to a flagship model only for complex reasoning and long-range refactoring.
- Retrieval instead of long context. Use vector or keyword retrieval to fetch relevant fragments rather than stuffing an entire repository into the context, which reduces both input cost and latency.
- Batching and asynchrony. Merge requests for offline tasks and schedule them off-peak, use streaming output to improve perceived responsiveness, and reduce duplicate calls caused by timeouts.
- Observability first. Build monitoring, alerting, and log auditing for token usage, cache hit rate, and cost per request, and attribute costs by business dimension, so you can pinpoint the real heavy consumers.
5. Subscription Plans vs. Pay-as-You-Go
Two supply models are common in the industry: a coding subscription with a fixed monthly fee in exchange for a quota, and a pay-as-you-go API billed by usage. Neither is absolutely better; the deciding factor is the load profile.
- Teams with stable loads, mainly interactive coding, and predictable monthly usage find subscriptions easier to budget for, and the unit cost is usually lower.
- Scenarios with highly variable loads, a need for elastic scaling, or calls coming from multiple business lines are better served by pay-as-you-go, which is more flexible but needs quota and budget alerts to go with it.
- A hybrid model is often optimal: cover baseline usage with a subscription and send peaks and bursts to pay-as-you-go, avoiding paying for peak capacity all the time.
When evaluating a plan, three things must be clear: whether the quota is converted by input and output or by request count, whether cache hits count toward the quota, and whether the quota carries over across cycles. Differences in these rules often affect total cost more than differences in the unit price itself.
6. A Selection Checklist
Before placing an order or signing a contract, run through these questions:
- What is the input-to-output ratio of the workload? Scenarios with a high output share are extremely sensitive to the output unit price.
- How repetitive are the request prefixes? For workloads with less than about 30% repetition, the benefit from cache discounts is limited.
- Can a small model serve as a fallback? If not, a sufficient budget must be reserved for the flagship model.
- Are there hard compliance and data residency requirements? These determine the available deployment options (public cloud API, dedicated instances, or on-premises).
- Are multimodal capabilities and ultra-long context needed? Both significantly raise the unit price and should be enabled on demand rather than turned on by default.
For cloud-based deployments, general-purpose capabilities can be combined as supporting pieces: object storage to archive corpora and artifacts, a message queue to smooth out peaks and fill troughs, a container platform to host the inference gateway and routing layer, and logging and monitoring services for cost attribution. Taking the relevant general capabilities of Baidu AI Cloud as an example, the engineering practice is typically to make cost governance a first-class citizen of the gateway layer rather than something you inspect after the bill arrives.
Conclusion
A several-fold increase in flagship model prices is essentially about making the real cost of compute explicit, while using cache discounts to reward call patterns that do not repeat computation. For developers, the right response is not to avoid flagship capabilities but to treat the call chain as an optimizable system: stabilize the prefix, compress the output, route by model tier, replace long context with retrieval, and attribute costs down to the business level. Do these things, and even as unit prices rise, the inference cost per unit of business value can keep falling.
