How Cache Hit Rate Affects Real LLM API Costs: A Practical Cost Estimation Method
This article explains why published token prices are not enough to estimate real LLM API costs. It presents a practical cost formula, shows how cache hit rate changes the cost structure, and discusses off-peak pricing, subscription plans versus pay-as-you-go billing, and engineering practices for reducing token costs.
How Cache Hit Rate Affects Real LLM API Costs: A Practical Cost Estimation Method
1. Why a Low List Price Does Not Mean Low Actual Cost
LLM API billing usually has three dimensions: input token price, output token price, and cache-hit token price. Many teams look only at the listed input and output prices when selecting a model or estimating a budget, but they ignore a key variable: cache hit rate. In real conversational and coding-assistant applications, context such as system prompts, conversation history, and code repository context appears repeatedly across requests. When this content hits the prefix cache, its billed price is significantly lower than that of regular input.
This leads to a counterintuitive conclusion: Model A may list a price twice that of Model B, but in a high-cache-hit scenario, the actual cost difference between them may be only about 30%. Conversely, in a low-hit scenario, the price ranking may even reverse. Therefore, any cost assessment must be based on your own traffic profile rather than on vendor marketing numbers.
2. The Basic Cost Formula
A general framework for cost per 100 million tokens is:
Total cost = cache-hit tokens × cache price+ regular input tokens × input price+ output tokens × output price
Because the output token price is usually much higher than the input price, often several times higher, its impact on total cost cannot be ignored even when output accounts for a small share of traffic. Suppose an application has the following traffic composition:
- Cache hit rate: 98%
- Regular input share: 1.5%
- Output share: 0.5%
This profile typically corresponds to a “long system prompt + multi-turn conversation” scenario, such as an intelligent coding assistant: the same repository context is injected repeatedly, and the model only needs to generate a small amount of completion code each time.
Using a typical price range—cache price around CNY 0.05–0.12 per million tokens, input price around CNY 0.2–0.4 per million tokens, and output price around CNY 1–2 per million tokens—the total cost per 100 million tokens falls roughly between CNY 10 and CNY 20. The key insight is that about 90% of the cost comes from cache-hit tokens at this point. The cache price becomes the decisive factor, while the input and output prices are largely diluted.
3. How the Cost Structure Reverses When Hit Rate Drops
If the cache hit rate falls from 98% to 95%, with the extra 3% billed as regular input, the cost structure changes substantially:
- The regular input token share rises from 1.5% to 4.5%, increasing threefold.
- Because the input price is several times the cache price, the cost increase contributed by this 3% of traffic far exceeds its token share.
Recalculating with similar proportions shows that the party that originally had the advantage may fall behind, while the party that originally looked more expensive may become more cost-effective. This means:
- Cache hit rate is the most sensitive variable in the cost model, more important than any price negotiation.
- For every one-percentage-point drop in hit rate, cost may rise by several percentage points.
- When evaluating model prices, you must obtain both the price list and your own business’s cache hit rate data.
A practical approach is to sample production traffic and measure the hit rate. Many platforms’ monitoring or logging services can analyze prefix repetition across requests. Then use the formula above to perform sensitivity analysis, plot a “hit rate–unit cost” curve, and identify your own decision threshold.
4. Time-Based Pricing: Off-Peak Usage as a Second Lever
Many vendors have introduced off-peak/peak time-based pricing for API billing, and the off-peak price may be half the peak price or even lower. For tasks that can run asynchronously, this is an almost zero-cost way to reduce expenses:
- Schedule batch document summarization, offline data cleaning, log analysis, model evaluation and benchmark scoring, and similar tasks to off-peak periods.
- Use message queues to smooth peaks and shift load, delaying non-real-time tasks that accumulate during the day until off-peak periods.
- Real-time interactive requests, such as customer service and coding assistants, cannot be moved, but cache optimization can be applied to them.
Note that vendors define “peak” periods differently: some have only a few peak hours per day, while others cover the entire working day. When choosing a time-based pricing option, focus on the length and overlap of peak periods, not just the size of the off-peak discount. The shorter the peak window, the higher the share of tasks that can be shifted, and the better the value of the subscription plan or off-peak pricing.
5. Pay-as-You-Go vs. Subscription Plans
In addition to token-based billing, mainstream vendors commonly offer monthly subscription plans, especially for coding-assistant scenarios. These usually come in lightweight, professional, and flagship tiers, each with different weekly or monthly token quotas.
To assess whether a plan is cost-effective, use a simple metric: the subscription discount ratio.
Subscription discount ratio = monthly subscription fee ÷ (cost of the same token quota at API list price)
A common industry ratio is roughly 50%–70%, meaning the subscription costs about 50%–70% of the API list price. However, three constraints also matter:
- Quota type: Some plans set separate limits for peak-period usage; after exceeding them, usage may be throttled or billed pay-as-you-go. Heavy users need to check carefully whether the peak quota is sufficient.
- Usage fluctuation: If team usage fluctuates widely, low-usage months dilute the benefit of the discount. A subscription is most cost-effective when daily usage is stable and close to the quota limit.
- Model scope: Confirm that the model versions covered by the plan meet your needs, and avoid choosing something that is cheap but unusable.
A simple decision rule: when the API cost equivalent of monthly token consumption exceeds 1.5× the subscription price, choose the subscription; when it is below 1.2×, pay-as-you-go is more flexible; in between, the decision depends on usage stability.
6. Engineering Cost-Reduction Checklist
Price is an external factor; architecture is an internal one. The following practices apply to any vendor:
- Maximize prefix cache hits: Put stable system prompts and tool definitions at the very beginning of the prompt, place dynamic content at the end, and keep the prefix byte-for-byte consistent.
- Control context length: Compress conversation history or use sliding-window truncation for multi-turn conversations to prevent useless tokens from being billed.
- Constrain output length: Limit generation length through explicit instructions or maximum output parameters. Since the output price is high, the savings are immediate.
- Route by model tier: Route simple tasks such as classification, extraction, and format conversion to lightweight models, and call flagship models only for complex reasoning.
- Monitor usage and set budget alerts: Use cloud platform logging and monitoring capabilities to split token consumption by application and by team, and set budget thresholds with automatic notifications.
7. Summary
The real cost of LLMs = price list × your traffic profile × engineering optimization level. The list price is only the starting point. Cache hit rate determines the main cost components, time-based scheduling provides a second discount, subscription plans suit stable heavy-load scenarios, and prefix cache optimization and model routing are long-term cost-reduction capabilities that no one can take away. Every team should build its own cost estimation table, calibrate it regularly with real data, and make sure every unit of budget is spent where it matters most.
