Input Cache Misses: How LLM API Billing Works and How to Control Cost
This guide explains input cache hits and misses in LLM API billing, how they differ from output token charges and time-of-day pricing, and how to estimate real cost and raise cache hit rates. It covers prefix matching, model-specific rules, cache expiry, scheduling, and usage monitoring.
Input Cache Misses: How LLM API Billing Works and How to Control Cost
1. What an “Input Cache Miss” Means
In mainstream LLM API services, the inference system often caches the context of a request’s input. When multiple requests share the same prefix—such as a system prompt, knowledge-base excerpts, or a long conversation history—the platform can reuse intermediate results that have already been computed and avoid repeating an expensive prefill. That reuse is an input cache hit.
When the input prefix does not match a cached key-value (KV) state, the system must run a full prefill. Billing systems often label that portion separately as input (cache miss). Its unit price is usually much higher than the cached portion.
A typical bill breaks usage into three dimensions:
- Input cache hit: the matched portion, billed at a lower unit price
- Input cache miss: the unmatched portion, billed at the standard input unit price
- Output: tokens generated by the model, billed at the output unit price
Understanding this split is the starting point for controlling LLM call cost.
2. Billing Rules Differ by Model
Cache pricing is not the same across model families. Some flagship models may not offer a cache discount, or they may use different hit/miss price ratios. Lightweight, low-latency models may use more granular cache billing. When choosing a model and estimating cost:
- Check the latest pricing documentation for the model you use and confirm whether cache billing is supported.
- Separate the unit prices for cache hits and cache misses.
- Do not apply one model family’s rules to another family.
Cache entries are also time-limited. If an entry is not hit for a while, it is evicted. If the gap between two requests is too long, an identical prefix can still be billed as a miss.
3. Peak and Off-Peak Pricing
Besides caching, many platforms use time-of-day pricing: token consumption is priced differently by time window. A common recent industry pattern looks like this:
- Weekdays: peak and idle (off-peak) windows, with peak prices higher than idle prices
- Weekends: some platforms stop distinguishing peak and off-peak and charge a single rate all day
- Scope: which models use these rules, and when they take effect, can differ by model family and should follow official announcements
For users, time-of-day pricing means cost depends on both token volume and when calls are made. Offline batch jobs scheduled into idle windows can significantly lower unit cost.
4. How to Calculate Actual Spend: An Example
Assume a model’s input pricing is:
Input cache-hit unit price = 25% of the standard priceInput cache-miss unit price = the standard priceOutput unit price = 4× the standard input price
In one request, the input is 8,000 tokens: 6,000 hit the cache and 2,000 miss. The output is 1,500 tokens. Then:
Input cost = 6000 × 0.25 × P + 2000 × 1 × P= 1500P + 2000P = 3500POutput cost = 1500 × 4P = 6000PTotal cost = 9500P
Even when output tokens are fewer, they can still account for more than half of the cost. Raising the cache hit rate from 75% to 90% lowers the input cost further. That is why production applications often treat “raise the cache hit rate” as the first optimization.
5. Practices That Raise Hit Rate and Lower Cost
5.1 Keep the input prefix stable
Cache matching is prefix matching. Put content that does not change at the front of the input:
[system prompt (fixed)] + [tool definitions (fixed)] + [business context (relatively stable)] + [this turn’s user input (variable)]
Do not put timestamps, random IDs, or request sequence numbers at the start of the prompt. If the prefix changes on almost every request, the hit rate approaches zero.
5.2 Reuse sessions and batch jobs
- In multi-turn conversations, keep the full history instead of rewriting it each turn, so the prefix stays stable.
- Offline batch jobs should share the same system prompt and knowledge-base template.
- Retrieval results from the same knowledge base should be concatenated in a deterministic order. Random ordering breaks prefix consistency.
5.3 Respect cache lifetime
For recurring jobs, schedule the interval shorter than the cache eviction window. Long-interval jobs can be grouped into idle periods so they also benefit from off-peak pricing.
5.4 Monitor and attribute usage
If the API returns usage fields for cache-hit and cache-miss token counts, send them to logs and alerts and break them down by business dimension:
- Cache hit-rate trend
- Share of tokens that miss the cache
- Consumption by time window (peak vs. off-peak)
- Average cost per request
If the hit rate drops unexpectedly, you can trace it to prompt-structure changes or upstream concatenation logic.
6. Cost Accounting for Teams
- Align the bill structure. Cost models should split input hits, input misses, and output. Estimating from a single “input tokens” figure will be biased.
- Separate rules by product line. Cache pricing can differ across model families, especially flagship versus lightweight models. Reports should be grouped by model.
- Use off-peak pricing. Schedule non-real-time work—corpus distillation, batch evaluation, document summarization, and similar jobs—into idle windows.
- Watch official announcements. Peak/off-peak windows, cache discount ratios, and effective dates change. Subscribe to change notices so budgets are not based on outdated rules.
- Make usage visible to end users. Some products already show per-turn consumption in the chat UI, split across the three billing dimensions, sometimes in a gradual rollout. Internal tools can do the same so people see token cost as they work.
7. Summary
An “input cache miss” is not just a line item. It is a core variable in LLM cost engineering. Use the three-part billing model, account for differences between model families, take advantage of peak and off-peak pricing, and keep raising the cache hit rate with stable prefixes, sensible scheduling, and usage monitoring. At scale, those steps produce meaningful savings. Teams should track cache hit rate and cost per request as ongoing technical metrics and update the strategy as pricing rules change.
