LLM Prompt Caching Pricing: How Cache-Hit Billing Cuts Input Costs
This article explains how cache-hit pricing works on a large language model (LLM) model-as-a-service (MaaS) platform, where a cloud provider reduced the cached input rate to 20% of the original price in one region while leaving all other billing items unchanged. It breaks down the input billing model into hit and miss segments, outlines the engineering constraints of prefix matching, and shows how to design prompts, manage conversation history, schedule requests, and handle multi-region deployments for higher hit rates. It also covers cost estimation, observability metrics, reliability risks, and a practical implementation checklist.
1. The Change: A Pricing Matrix Adjustment, Not a Broad Price Cut
A cloud provider recently announced that, starting November 23, 2026 at 00:00 (Beijing time), it will lower the input billing rate for a specific LLM service on its model-as-a-service (MaaS) platform in the Guiyang region. The cached-input portion is repriced to 20% of the original rate; all other billing items remain unchanged.
Reading this as a “price cut” is not quite accurate. It adjusts a single cell in the billing matrix—the cached-input unit price—while uncached input, output, and any other billing items stay as they were. The actual change on your bill therefore depends entirely on whether your workload can turn requests into cache hits. For callers with a hit rate near zero, the bill barely moves; for high-hit-rate scenarios, input costs can drop by an order of magnitude.
This is the premise for all optimization work that follows: the benefit is not universal, but strongly tied to architecture design.
2. Billing Model Breakdown: How a Request Is Split
Input billing for mainstream LLM services is usually not a single price, but two segments based on whether the prefix can be reused:
- Uncached input (cold prefix): the portion that requires full attention computation, at the highest unit price;
- Cached input (hot prefix): the context prefix shared with prior requests, which needs no recomputation and is priced significantly lower;
- Output: billed per generated token, generally unaffected by caching.
The billing logic in pseudocode:
def estimate_cost(req, price):shared = longest_common_prefix(req.prompt, cache_index)hit_tokens = len(tokenize(shared))miss_tokens = len(tokenize(req.prompt)) - hit_tokensreturn (hit_tokens * price.hit_input+ miss_tokens * price.miss_input+ len(req.output) * price.output)
The key is longest_common_prefix: the cache reuses a prefix that is token-for-token identical. A single differing character, a timestamp, or a random ID truncates the match at that point, and everything after it degrades to uncached.
3. Engineering Constraints on Hit Determination
To actually get the discount, you need to understand several hard constraints of the matching mechanism:
- Strict prefix matching. The cache is a prefix-tree structure and does not allow “middle reuse.”
- Order sensitivity. Putting stable content first and volatile content last is the first principle of hit rate.
- Minimum cacheable length. Providers typically set a minimum token threshold; prefixes shorter than it do not enter the cache, so fragmented system prompts benefit little.
- Capacity and eviction. Cache space is limited and uses an approximate LRU eviction policy, so long-tail prefixes get pushed out.
- Propagation delay. Newly written prefixes take time before they can be hit by later requests, so traffic during cold start gets no discount.
- Isolation boundaries. Caches are generally isolated by account/tenant and region, so cross-region deployments cannot share them.
4. Architecting for a High Hit Rate
4.1 Prompt Layering
Order the prompt by “frequency of change,” from low to high, to form a stable long prefix:
[Layer 1] Role definition, safety policy, output format constraints — almost never changes[Layer 2] Domain knowledge, glossary, tool descriptions — changes by version[Layer 3] A few examples (few-shot) — changes by task type[Layer 4] Conversation history summary — grows slowly[Layer 5] Current user input, timestamp, session ID — changes every time
The anti-pattern is equally clear: concatenating the current time, a request ID, or a random nonce into the system prompt makes the entire prefix permanently unhittable.
4.2 Conversation History Management
Multi-turn dialogue is the scenario that most easily wastes cache. If every turn reassembles the full history and that history carries volatile fields, the hit rate decays quickly. A workable approach: produce a structured summary of the history with a fixed serialization format (stable key order, no random map ordering), and place only the latest turn at the end.
4.3 Batching and Concurrent Scheduling
Cache hits show clear temporal locality. Aggregating requests with the same prefix within a short time window can significantly raise the hit rate:
# Pseudocode: group by prefix fingerprint and prioritize same-group requestsgroups = defaultdict(list)for req in pending:groups[prefix_fingerprint(req.prompt)].append(req)schedule(groups) # send same-group requests back to back to use the warm cache
4.4 The Multi-Region Trade-off
Because caches are isolated per region, spreading traffic across regions lowers the hit rate within any single region. If cost is the priority, converge requests with the same class of prefix into one region; if latency is the priority, accept partial loss of hit rate and discount, and account for it explicitly in the cost model.
5. Cost Estimation Method
Build a reproducible estimation table rather than judging the benefit by feel:
hit_ratio = 0.85 # measured hit ratelen_prefix = 6000 # stable prefix tokenslen_query = 800 # new tokens per turnhit_factor = 0.20 # discount factor from the announcementcost_before = (len_prefix + len_query) * p_incost_after = (len_prefix * hit_ratio * hit_factor+ len_prefix * (1 - hit_ratio)+ len_query) * p_in
Plugging in typical values shows that when the hit rate exceeds 0.8 and the stable prefix accounts for more than 80% of the input, input-side cost can fall by roughly 60%–70%; output cost is unchanged, so the overall benefit is diluted for long-output workloads. This is why a pricing announcement must be read together with the workload profile.
6. Observability: Make Hit Rate a First-Class Metric
No measurement, no optimization. At minimum, collect four metrics:
- Hit rate: hit tokens / total input tokens;
- Prefix length distribution: reveals waste from “prefixes too short to cache”;
- Truncation position: pinpoints which volatile field broke the match;
- Per-request cost: the real unit price weighted across hits and misses.
With logging and monitoring alerts, you can set a hit-rate threshold so that if a release breaks the prefix structure, you catch it before the bill deteriorates.
7. Reliability and Risks
- Discount correlates with capacity: a higher hit rate occupies more cache capacity, so eviction risk must be assessed;
- Roll out changes gradually: validate hit rate with a small traffic share before going full scale;
- Do not trade correctness for savings: reusing stale knowledge to keep the prefix identical introduces factual errors;
- Reconcile billing: after the price change takes effect, compare the actual unit price before and after to confirm the discount landed.
8. Implementation Checklist
- Audit existing prompts, flag all volatile fields, and move them to the end;
- Fix the serialization format; prohibit random key order and implicit timestamps;
- Build a dashboard for hit rate and per-request cost;
- Aggregate same-prefix requests with time-window scheduling;
- Converge region distribution, or account for isolation loss in the cost model;
- Complete a full estimation and gradual rollout before the price change takes effect.
