LLM API Pricing Increases: The Compute Logic Behind Token Costs and Practical Cost Optimization
This article explains why LLM API prices are rising by breaking down the compute economics of inference: GPU memory usage, compute consumption, and context length. It examines three-tier pricing for input, output, and cache-hit tokens, shows how prefix caching shifts repeated work off the bill, and argues that list price alone does not determine real spending. Readers will find practical optimization techniques, including prefix stabilization, output length controls, model routing, batching with backoff, and observability, plus a unified formula for comparing effective cost per million output tokens.
1. The Phenomenon: The Compute Ledger Behind Higher Unit Prices
The industry has recently seen a clear round of price adjustments: a new generation of general-purpose LLMs is priced several times higher than the previous generation, with output reaching the order of a hundred yuan per million tokens, input around twenty yuan, and cache hits around one yuan. The first developer reaction is usually “prices went up.” But placing these three tiers in the coordinate system of compute supply makes it look more like a making-explicit of cost structure.
To be clear, this article does not evaluate any specific vendor’s pricing or recommend any product. The discussion uniformly abstracts the subject as “a class of large language model inference services.” The price figures are only order-of-magnitude illustrations used to explain the billing structure.
The cost of LLM inference consists of three parts:
- GPU memory usage: Weights and the KV cache reside in GPU memory, determining the concurrency ceiling a single card can support;
- Compute consumption: Autoregressive decoding is token-by-token serial computation, and every step of the output phase reads all weights, making it a typical memory-access-intensive workload;
- Context length: Attention computation and the cache grow with sequence length, so the marginal cost of long contexts is far higher than that of short requests.
New-generation models typically come with larger parameter counts, longer context windows, and more intermediate computation steps in the inference pipeline. These three factors combine to raise the real resource consumption per token. The price increase is therefore not purely a commercial strategy, but the joint result of tight compute supply and upgraded model capabilities.
2. The Substance of Three-Tier Pricing: A Fine-Grained Resource Layering
Splitting pricing into input, output, and cache hit into three tiers essentially strips “repeated computation” out of the bill.
| Billing tier | Resource profile | Relative unit price | Typical use case |
|---|---|---|---|
| Input | First-time prefill, requiring a full forward pass | Medium | Newly added context each turn |
| Output | Token-by-token decoding, serial and memory-access-intensive | High (several times input) | Generating body text, code completion results |
| Cache hit | Reusing already-computed key-value cache, skipping prefill | Very low | System prompts, long documents, fixed knowledge snippets |
Cache hits can be pushed to a very low price because the server does not need to repeat the prefill stage; it directly reuses the resident key-value cache, saving real compute. This also sends developers a clear optimization signal: anything carried repeatedly in every request should be turned into a cache hit.
An illustrative way to organize a request:
def build_request(system_prompt: str, history: list, user_input: str):# Put the fixed prefix first to keep it byte-level stable and improve cache reusemessages = [{"role": "system", "content": system_prompt}]messages.extend(history)messages.append({"role": "user", "content": user_input})return {"messages": messages,# Output length is the main cost driver and should be constrained explicitly"max_tokens": 1024,"temperature": 0.2,}
There are three hard engineering constraints: the prefix must be byte-for-byte stable, and any timestamp, random identifier, or dynamic retrieval result inserted into the prefix will invalidate the cache; new content can only be appended at the tail; and output length must be explicitly capped, because it is the highest unit-price part of the bill.
3. The Overlooked Variable: List Price Does Not Equal Actual Spend
The most valuable point in the original observation is this: the API list price is only a suggested retail price; real perceived cost is determined by quota policy.
Subscription plans and pay-as-you-go billing are two different resource allocation logics. Pay-as-you-go is linear and predictable: you pay for what you use. A subscription plan is a pooled model of “total quota + periodic reset,” and the actually available amount depends on rules such as reset frequency, per-period caps, and whether separate pools are accounted separately. When the provider increases reset frequency or relaxes the per-period cap, the effective unit cost for subscription users drops significantly, and a clear gap emerges between the pay-as-you-go list price and the subscription experience.
This produces a counterintuitive conclusion: in high-frequency interaction scenarios, the party with the lower list price is not necessarily cheaper. If different billing pools are accounted separately (for example, conversation and code execution are metered independently), the actually available total is discounted further.
Evaluating cost therefore requires the same basis, and it is recommended to convert everything to “combined cost per million effective output tokens”:
combined cost = (input tokens × input price + output tokens × output price+ cache-hit tokens × cache price) / effective output tokens× (1 + retry rate) × (1 + invalid generation rate)
The retry rate and invalid generation rate are the two most easily missed items. One timeout retry, or one regeneration due to format mismatch, will make the actual bill deviate from the theoretical value.
4. Cost Optimization Practices
4.1 Prefix Fixation and a Cache-Friendly Architecture
Place static content such as system prompts, tool definitions, few-shot examples, and long documents at the front and manage them with versioning, replacing the whole thing on change rather than making local edits. In retrieval-augmented scenarios, retrieval results should be placed at the tail of the context rather than concatenated into the prefix.
4.2 Output Length Governance
Output has the highest unit price, so engineering constraints are required: use schema validation to limit fields for structured output, restrict code generation to returning snippets rather than whole files, set explicit word limits for summarization tasks, and use streaming responses to terminate early when redundancy is detected.
4.3 Model Tiered Routing
Not every request needs the strongest model. Small models can handle intent recognition, format conversion, and simple extraction, while only complex reasoning and long-chain code tasks are handed to high-capability models.
def route(task):if task["complexity"] == "low":return "light-model" # Lightweight model, low costif task["context_tokens"] > 60000:return "long-context-model"return "flagship-model" # Flagship model, highest cost
4.4 Request Batching and Failure Backoff
Merging small requests, controlling concurrency, and applying exponential backoff to failed requests instead of retrying immediately can reduce both wasted consumption and rate-limiting risk.
4.5 Observability First
The prerequisite for cost governance is visibility. It is recommended to add unified instrumentation at the gateway layer, recording input/output/cache-hit token counts, latency, and failure reasons for each call, and to use monitoring alerts and log services for day-over-day comparison and anomaly detection, turning “checking the bill at month end” into “watching the trend the same day.”
5. Conclusion
The price increase is an objective result of the joint effect of compute supply and model capability upgrades, and three-tier differentiated pricing gives a clear optimization direction: stabilize the prefix, control output, and route by tier. What developers really need to focus on is not the decimal point of the list price, but the three variables that determine actual spend: quota rules, cache hit rate, and invalid call rate. Unifying the cost measurement basis and building observability is what keeps bills predictable during a period of rising prices. For teams with compliance and elasticity needs, using a container platform to host self-built inference services, archiving logs with object storage, and reserving a multi-provider abstraction layer is a general practice for reducing the risk of changes to a single billing policy.
