LLM API Cache Hit Pricing: A Practical Guide to Cutting Input Costs
This article breaks down a recent LLM API pricing change that reduces input billing for cache hits to 20% of the original rate in a specific region. It explains how prefix caching works, presents a cost model showing how input cost scales with the cache hit ratio, and outlines design patterns for improving hit rates—prefix layering, incremental conversation appends, template-aligned batching, and input normalization. It also covers observability, common pitfalls, and a practical rollout checklist for engineering teams.
1. Background: A Typical Inference Pricing Adjustment
A cloud provider’s model-as-a-service platform announced that, starting November 23, 2026, at 00:00 (Beijing time), it will lower the inference price of a general-purpose chat model in a specific region: the input billing for cache hits is adjusted to 20% of the original price, while all other billing items remain unchanged.
This announcement carries a high density of information and is worth unpacking layer by layer:
- Limited scope: It applies to a single region only, indicating that resource supply and cost structures differ across regions and that pricing is set independently per region.
- Only one item changed: Only “cache-hit input” is discounted; output and cache-miss input prices stay the same. This is a structural cost incentive, not an across-the-board price war.
- Significant reduction: The hit portion drops to 20% of the original price, widening the cost gap between hits and misses to roughly 5x and directly amplifying the payoff of architectural design.
For consumers, this is not a “wait for the notice” event but a clear optimization signal: the billing structure is turning “whether context is reused” into a quantifiable engineering metric.
2. How It Works: Why Prefix Caching Saves Money
LLM inference has two phases. The prefill phase reads all input tokens and computes attention keys and values, with compute growing as input length increases. The decode phase generates output tokens one by one. In most chat and batch scenarios, input is far longer than output, so prefill is the main source of compute consumption.
The core assumption of prefix caching is: if two requests share an identical input prefix, the intermediate state for that prefix can be reused without recomputation. The server typically hashes at token-sequence granularity and, on a hit, loads the cached state directly and computes only the newly appended tail tokens incrementally.
This yields several hard constraints:
- Matching is strictly token-by-token; a single punctuation mark, space, or changed timestamp invalidates everything after it.
- Caches have a lifecycle, subject to capacity eviction and expiration policies; prefixes idle for a long time may be reclaimed.
- A hit generally requires the prefix to be at the start of the request; stable content inserted in the middle or at the end cannot benefit from reuse.
Understanding these three points explains why a “price cut” does not automatically mean “saving money”—whether the discount materializes depends on how requests are constructed.
3. Cost Model: Turning the Discount into Comparable Numbers
Let the original input unit price be P_in, the output unit price be P_out, a request have L_in input tokens and L_out output tokens, and the cache hit ratio be h. The cost per request is:
Cost = L_in * P_in * (1 - h + 0.2 * h) + L_out * P_out= L_in * P_in * (1 - 0.8h) + L_out * P_out
Key takeaway: input-side cost decreases linearly with the hit ratio. At h=0 there is no benefit; at h=0.5 input cost drops to 60% of the original; as h→1 it approaches 20% of the original. Output cost is entirely unaffected.
This leads to an important engineering judgment: optimization should focus on long-input, short-output tasks. Examples include codebase Q&A, long-document summarization, log and ticket classification, and batch extraction, where inputs often run into thousands or tens of thousands of tokens and the payoff is substantial. Conversely, short prompts and long-form creative tasks have naturally low hit ratios, making architectural rework a poor return on investment.
4. Design Patterns for Improving Hit Rates
4.1 Prefix Layering: Put Stable Content First
Order request content from lowest to highest change frequency to form a stable prefix plus a dynamic tail:
[System instructions] ← almost never changes, longest, best for caching[Domain knowledge/tool descriptions] ← updated by version[Few-shot examples] ← relatively fixed[Conversation history] ← appended each turn[Current user input] ← changes every time
The anti-pattern is putting timestamps, random IDs, or usernames at the beginning, which invalidates the entire prefix every time.
4.2 Incremental Conversation Appends
For multi-turn conversations, do not rewrite the full context each turn; instead, append new content to the end of the previous request. The input prefix of turn N then contains all of turn N-1, naturally forming a chained hit.
4.3 Task Alignment in Batching
Batch jobs should group requests with the same template and send them consecutively, avoiding cache thrashing caused by alternating templates:
# Recommended: group by template so the long prefix is shared within a groupbuckets = defaultdict(list)for item in tasks:buckets[item.template_id].append(item)for template_id, items in buckets.items():system_prompt = build_prompt(template_id) # stable prefixfor it in items:call_model(system_prompt, it.payload) # tail varies, prefix reused
4.4 Content Normalization
Apply deterministic preprocessing to inputs: unify whitespace and line breaks, fix number and unit formats, and sort and deduplicate retrieved snippets. The goal is to ensure that “two semantically identical requests are also byte-for-byte identical.”
5. Observability and Verification
Whether the discount lands must be validated with data. Build a minimal closed loop:
- Instrumentation: Log input/output token counts, cached token counts, hit flags, latency, and billed amount for each request.
- Metrics: The core metric is the cache hit ratio
h = cached input tokens / total input tokens, supplemented by average cost per request and P95 latency. - Load testing: Replay real traffic to compare before and after the change, observing hit ratio and billing changes while confirming no regression in output quality.
- Alerting: A hit ratio falling below a threshold usually means the prefix was polluted or the cache expiration policy changed, and should trigger investigation.
Pseudocode:
def report(req_id, in_tok, cached_tok, out_tok, latency_ms, cost):metrics.emit("cache_hit_ratio", cached_tok / max(in_tok, 1))metrics.emit("cost_per_request", cost)metrics.emit("latency_p95", latency_ms)if cached_tok == 0 and in_tok > 2000:alerts.warn(f"Long input with zero hits: {req_id}")
6. Common Pitfalls
- Assuming the discount covers all input: Only the hit portion is discounted; misses are still billed at the original price.
- Embedding random values in prompts: Debug IDs and current time should go at the tail or be replaced with fixed placeholders.
- Blindly lengthening context: On a miss, an overly long input amplifies cost; validate the hit ratio before expanding context.
- Assuming prices are consistent across regions: Pricing and capabilities are configured independently per region; treat region as a switchable parameter in your architecture.
- Looking only at unit price, not structure: The real lever is the hit ratio; the unit-price discount is just a multiplier.
7. Rollout Checklist
- Inventory existing request templates, annotate the update frequency of each segment, and reorder them into a stable-prefix structure.
- Version system instructions and knowledge snippets to avoid frequent changes that invalidate the cache.
- Group batch jobs by template and submit them serially.
- Build a dashboard for hit ratio and cost per request, with threshold-based alerts.
- Validate in a canary region first, then roll out to all traffic.
- Review the cost model quarterly, since pricing and caching policies keep changing.
In summary, this discount on cache-hit input turns cost pressure into an architectural signal: whoever organizes context to be more stable and reusable captures close to an 80% reduction in input cost. For developers, the worthwhile investment is not chasing lower unit prices but making “cacheability” a first-class citizen in system design.
