LLM API Pricing Tiers and Cache Billing: A Practical Guide
This guide explains how modern LLM API pricing is split across input tokens, cached input tokens, and output tokens, and why the same model can produce very different bills. It breaks down the billing logic of each token type, provides a reusable cost estimation model with worked examples for high-performance and lightweight tiers, and covers engineering practices for raising cache hit rates, such as layered prompt structure, eliminating prefix jitter, deterministic ordering of retrieved results, and output-side constraints. It also outlines observability and cost governance metrics, plus model selection recommendations for different workloads.
1. The Starting Point: Why the Same Model Can Produce Very Different Bills
In enterprise LLM applications, inference cost is often determined not by “how many times you called the API” but by the structure of tokens. A typical request carries three kinds of overhead: the context sent to the model (input), the content the model generates (output), and the shared prefix that repeatedly appears in multi-turn conversations or batch processing (cacheable input). These three consume different amounts of compute, which is why the industry generally uses tiered pricing rather than a single flat rate.
A recent dual-version pricing adjustment from a cloud provider illustrates this tiered approach: the high-performance version was cut by roughly 20% overall, with a larger discount on cache-hit portions, while the lightweight version kept its original price. The engineering implication goes far beyond “it got cheaper” — it shifts the focus of cost optimization from “call less” to “how you organize context.”
2. Breaking Down the Billing Logic of the Three Token Types
2.1 Input Tokens: Billed in Full, Cost Grows with Context
Input pricing is usually quoted per million tokens. The high-performance tier commonly sits in the single-digit dollar range, while the lightweight tier sits at the low end of single digits. Note that input cost scales linearly with the actual length of text sent. For scenarios like long-document summarization or full-codebase Q&A, the input side often accounts for more than 60% of the total bill.
2.2 Cached Input Tokens: The Biggest Discount, but Conditional on Cache Hits
Cached input is typically priced at one-tenth of standard input or even lower. The principle is that when multiple requests share an identical prefix (system prompt, tool definitions, long document body, few-shot examples), the inference side can reuse the already-computed intermediate state and skip redundant computation.
Hitting the cache usually requires a few general conditions:
- The prefix must be byte-for-byte identical; any timestamp or random ID will invalidate it.
- The prefix must sit at the very front of the prompt and reach the platform’s minimum length threshold.
- The cache has a time-to-live and must be recomputed after it expires.
2.3 Output Tokens: The Highest Unit Price and the Main Cost Amplifier
The output unit price is usually several times that of input. The reason is that autoregressive generation cannot be parallelized — every token must go through a full forward pass. As a result, controlling output length (structured output, limiting max tokens, avoiding verbose explanations) often yields more savings than compressing input.
3. Cost Estimation: A Reusable Model
Let the input tokens be $I$, the cache-hit portion be $I_c$, and the output tokens be $O$. The cost of a single request can be approximated as:
Cost = (I - Ic) / 1e6 * P_in+ Ic / 1e6 * P_cache+ O / 1e6 * P_out
Using the high-performance tier (input about $8, cache about $0.4, output about $40 per million tokens) and the lightweight tier (input about $2, cache about $0.1, output about $10 per million tokens) as examples, for a request with 4,000 input tokens (3,600 of them cacheable) and 500 output tokens:
High-performance: 4000-3600=400 → 0.00323600 → 0.00144500 → 0.02Total ≈ $0.0246Lightweight: 400 → 0.00083600 → 0.00036500 → 0.005Total ≈ $0.0062
The conclusion is intuitive: on the high-performance tier, cache hits compress input-side cost by roughly an order of magnitude, but output still dominates. This also explains why “output length governance” is often more effective than “switching to a cheaper model.”
4. Engineering Practice: Raising the Cache Hit Rate
4.1 Layered Prompt Structure
Split the prompt into a “stable layer — semi-stable layer — dynamic layer.” Put the system role and tool definitions in the stable layer, knowledge snippets in the semi-stable layer, and user input in the dynamic layer. Once the order is fixed, the prefix can be reused over the long term.
[Stable layer] Role setup + output format constraints + tool schema[Semi-stable layer] Retrieved document snippets (in a fixed order)[Dynamic layer] The current user question
4.2 Eliminating Prefix Jitter
Common “cache killers” include putting dates, request IDs, or randomly ordered retrieval results at the front; re-ranking documents in real time; and concatenating volatile fields such as user nicknames into the prompt. It is recommended to hash-check the prefix and track the hit rate during a canary rollout.
4.3 Deterministic Ordering of Retrieval Results
If you use knowledge-base augmentation, sort the retrieved snippets by a fixed rule (such as ascending document ID) before concatenation, so that slight changes in similarity scores do not reorder them and invalidate the whole cache.
4.4 Output-Side Constraints
Prefer structured output and explicit word limits. Splitting “explanatory long-form” content into multiple short requests is often cheaper than one long output and makes cache reuse easier.
5. Observability and Cost Governance
It is recommended to bring token usage into the monitoring and alerting system, tagged by business line, scenario, and model tier. Core metrics include cache hit rate, average input/output tokens, cost per request, and failure retry rate. Keep desensitized usage details in the logging service to make it easier to trace abnormal bills. For cost-sensitive paths, you can set budget thresholds and automatic fallback policies: route to the lightweight tier first, and escalate to the high-performance tier only when the cache misses or quality falls short.
6. Selection Recommendations
- High-complexity reasoning and long-chain agent tasks: choose the high-performance tier and enforce cache reuse.
- High-concurrency, short Q&A, classification, and extraction tasks: the lightweight tier offers better cost-performance.
- Hybrid architecture: routing by task difficulty at a routing layer is the mainstream approach for balancing quality and cost.
Overall, tiered pricing and cache billing turn “context engineering” into part of cost engineering. Understanding the unit-price differences among the three token types, how to construct a stable prefix, and how to constrain output length lets you keep the inference bill within a predictable range without sacrificing quality.
