How Cache Hit Rates Reshape the Real Cost of LLM Inference
LLM inference pricing cannot be evaluated accurately by looking only at the advertised price per million tokens. This article explains how cache hit rates, input-to-output ratios, and output pricing combine to determine effective unit cost, using illustrative relative prices and practical formulas. It also covers workload differences, cache-friendly engineering practices, routing strategies, and a framework for evaluating inference services.
How Cache Hit Rates Reshape the Real Cost of LLM Inference
1. Advertised Price and Effective Price Are Not the Same
The most common mistake when evaluating large language model inference costs is to look only at the advertised price per million tokens. In practice, inference pricing is usually divided into at least three categories:
- Uncached input tokens
- Cached input tokens
- Output tokens
These categories can have very different price weights, and their relative pricing may change across product generations. As a result, a new-generation model having an output price several times higher does not necessarily mean that every user’s real unit cost has increased by the same multiple.
A more useful metric is the effective unit price. This metric incorporates the input-side cache hit rate and then combines input and output costs according to the workload’s token ratio. It provides a closer approximation of the actual bill for a given application.
The examples below use illustrative relative prices to demonstrate the calculation method. Assume the cached input price is 1 price unit, the uncached input price is 10, and the output price is 50. For the previous generation, the corresponding ratios were approximately 6x and 25x; for the new generation, they increased to 10x and 50x. These ratios are used only to illustrate changes in pricing structure and do not represent the pricing of any specific provider.
2. A Shift in Pricing Structure: Larger Cache Discounts and Higher Output Premiums
The illustrative ratios indicate that the change is not simply an across-the-board price increase. Instead, the pricing structure has shifted:
- Cached input pricing increases relatively moderately.
- Uncached input pricing increases by a medium amount.
- Output pricing increases more significantly.
- The ratio of uncached input price to cached input price rises from approximately 6x to 10x.
- The ratio of output price to cached input price rises from approximately 25x to 50x.
This means workloads with high cache hit rates receive a stronger structural discount, while workloads with low cache hit rates and a high proportion of output tokens move closer to the combined cost of uncached input and output tokens.
In other words, the same model can have dramatically different real costs depending on the workload. The difference may reach several times the advertised price.
3. Two Formulas: Effective Input Price and Blended Unit Cost
Let:
- (h) be the cache hit rate
- (P_h) be the cached input price
- (P_m) be the uncached input price
- (P_o) be the output price
- (r) be the input-to-output token ratio, defined as input tokens divided by output tokens
The effective input price is:
[
P_{in}^{eff}=P_h \times h + P_m \times (1-h)
]
The blended cost per million total tokens is:
[
C{blend}=\frac{r \times P{in}^{eff}+P_o}{r+1}
]
Here, (C_{blend}) represents the average cost per million combined input and output tokens. The calculation can be implemented as follows:
function effective_input_price(h, Ph, Pm):return Ph * h + Pm * (1 - h)function blended_cost(h, Ph, Pm, Po, r):Pin = effective_input_price(h, Ph, Pm)return (r * Pin + Po) / (r + 1)
The value of this formula is that it converts an advertised price into a real unit price based on a specific workload profile. During procurement or architecture evaluation, teams should first estimate (h) and (r) for each business scenario and then apply the formulas.
4. Example: Two Workloads Can Differ by Several Times Under the Same Pricing
Continue using the illustrative relative prices:
[
P_h=1,\quad P_m=10,\quad P_o=50
]
Enterprise Agent workloads often involve long contexts, stable system prompts, reusable tool definitions, and multi-turn task chains. Their input-to-output ratio may be relatively high. Consider an example with (r=20) and a cache hit rate of (h=90\%):
[
P_{in}^{eff}=1 \times 0.9 + 10 \times 0.1 = 1.9
]
[
C_{blend}=\frac{20 \times 1.9 + 50}{21}\approx 4.19
]
In a low-frequency development or exploratory workload, prompts may change frequently. The cache hit rate might be only 20%, with an input-to-output ratio of 5
[
P_{in}^{eff}=1 \times 0.2 + 10 \times 0.8 = 8.2
]
[
C_{blend}=\frac{5 \times 8.2 + 50}{6}\approx 15.17
]
The blended unit costs differ by approximately 3.6 times.
Therefore, behind the appearance of an across-the-board price increase, enterprise workloads with high cache hit rates and high input-to-output ratios may achieve an effective price closer to the discounted cached rate. Workloads with low cache hit rates and a high proportion of output tokens will be closer to the uncached and output rates.
5. Why Cache Hit Rate Has Become a Critical Cost Lever
In long-context coding, knowledge base question answering, and tool-using Agents, system prompts, tool definitions, codebase summaries, and fixed examples often account for a large share of input tokens.
If these prefixes remain stable and can be reused, improving the cache hit rate directly reduces the effective input price. Common technical approaches include disaggregated inference architectures, shared cache pools, prefix reuse, and scheduling optimization.
However, architecture alone does not determine the final cache hit rate. It also depends on:
- Workload stability
- Prefix consistency
- Tenant isolation
- Cache invalidation policies
- Request routing design
Cache reuse does not automatically become effective simply because it has been enabled. If every request inserts a random timestamp, random ID, or dynamically sorted tool list into the prefix, the reusable cache prefix may be broken. A high cache hit rate requires both suitable architecture and consistent engineering practices.
6. Engineering Optimization Checklist
Keep prefixes stable: Preserve the order of system prompts, tool schemas, examples, and fixed instructions. Avoid inserting dynamic content into the prefix.
Layer the context: Place static knowledge at the beginning and dynamic retrieval results later in the context. Summarize and compress conversation history when appropriate.
Control output generation: Set reasonable maximum output lengths and stopping conditions. Use structured output and summarization strategies to reduce the share of high-priced output tokens.
Use tiered routing: Send simple tasks to smaller models or rule-based systems, and escalate only complex tasks. Route highly reusable workloads through cache-friendly paths.
Batch and process asynchronously: Combine non-real-time tasks where possible to improve resource utilization.
Make cost observable: Track cache hit rate, input-to-output ratio, effective input price, and per-task cost by tenant, scenario, and task type. In general-purpose cloud environments such as Baidu AI Cloud, teams can combine logging, monitoring and alerting, and object storage capabilities to build a cost-observability workflow.
Maintain cache consistency: Version prefixes to prevent stale cache entries from affecting results. Isolate sensitive data by tenant.
7. A Framework for Model Selection and Procurement
When evaluating a new inference service, create a workload profile that estimates the following values for both peak and normal usage:
- Cache hit rate (h)
- Input-to-output ratio (r)
- Average output length
- Concurrency
- SLA requirements
Then perform a sensitivity analysis. For example, set (h) to 50%, 70%, and 90%, and set (r) to 5, 10, and 20 to observe how the blended cost changes.
If a workload has a low cache hit rate and long outputs, output pricing and output controls should be the primary focus. If it has a high cache hit rate and a large proportion of input tokens, cache mechanisms, prefix reuse, and tenant isolation become more important.
8. Conclusion
An increase in inference pricing should be understood as a signal about the pricing structure: output tokens are becoming more expensive, while cache reuse is becoming more valuable.
Organizations should not compare inference services solely by their advertised price per million tokens. Instead, they should calculate the effective input price and blended cost based on their own workload characteristics.
By stabilizing prefixes, compressing context, controlling output, applying tiered routing, and monitoring costs, teams can turn a high cache hit rate into a sustainable engineering capability. This is how they can achieve a lower real unit cost while maintaining the same level of model capability.
