# Understanding LLM Prompt Caching Pricing: How Much Can You Cut API Costs?
Discounted LLM pricing often comes with the fine print of cached input, uncached input, and output token rates. This article breaks down how these three billing categories work, walks through a real-world cost calculation for a full-project code audit, and shows how to compare providers and budget for API costs when promotional prices end.
1. After the Price Cut: How Is Your Bill Actually Calculated?
Announcements about LLM price cuts usually lead with a discount percentage, but your actual bill depends on three billing categories: input tokens that hit the cache, input tokens that miss the cache, and output tokens. The prices used in this article are example figures to demonstrate the calculation method only—they do not represent any provider’s actual pricing. Before budgeting, always check your provider’s official documentation for the latest price list.
2. Three Billing Categories and Example Prices
| Billing category | Standard price (per million tokens) | Example promotional price (per million tokens) | Reduction |
|---|---|---|---|
| Input, cache hit | 1 | 0.25 | 75% |
| Input, cache miss | 12 | 3 | 75% |
| Output | 24 | 6 | 75% |
In both price sets, cached input costs 1/12 of uncached input, and output costs twice as much as uncached input.
Why is a cache hit cheaper? When an LLM processes input, it first runs a forward pass over the entire context to generate the KV Cache. This step consumes significant GPU compute. If a new request’s prefix is identical to a previous request, the provider can reuse the existing KV Cache and skip that computation—hence the lower price.
A few conditions affect cache hits:
- The prefix must match exactly from the first character. A single differing character in the middle means everything after it is billed as a cache miss.
- Caches have a time-to-live. Once it expires, the same prefix is recomputed.
- Rules vary by platform. Some charge for cache writes or cache storage. Check the relevant API documentation before use.
Why is output the most expensive? The model generates output tokens one at a time, running a full forward pass for each token. Unlike input processing, this cannot be parallelized, which is why output tokens typically cost far more than input tokens.
These patterns suggest a practical approach: place stable content such as system instructions, tool definitions, and domain knowledge at the very beginning of the prompt, and put request-specific content at the end.
3. Cost Estimate: A Full-Project Code Audit
Here is a worked example using a full-project code audit, with these assumptions:
- The project contains roughly 100,000 lines of code.
- A complete scan consumes 3,000,000 input tokens in total, including code read repeatedly across multiple rounds of tool calls.
- Of these, 2,000,000 input tokens hit the cache: the system prompt, audit guidelines, and shared repository context.
- The remaining 1,000,000 input tokens miss the cache.
- The model outputs 30,000 tokens—the audit report and remediation recommendations.
- No cache write fees and no retries are included. If your platform has additional charges, add them yourself.
The cost calculation:
| Item | Tokens | Promo price (per million) | Promo cost | Standard cost |
|---|---|---|---|---|
| Input, cache hit | 2,000,000 | 0.25 | 0.50 | 2.00 |
| Input, cache miss | 1,000,000 | 3 | 3.00 | 12.00 |
| Output | 30,000 | 6 | 0.18 | 0.72 |
| Total | 3.68 | 14.72 |
At standard prices, the same audit costs about 4x the promotional price. The cache hit rate here is 2,000,000 / 3,000,000, or roughly 66.7%.
The value of caching becomes clear with a reverse calculation. If every input token missed the cache, the promotional cost would be 3,000,000 × 3 / 1,000,000 + 0.18 = 9.18—5.50 more than with caching. For workloads with long contexts and highly repetitive prefixes, the hit rate often matters more than the per-token price itself.
4. How to Compare Prices Across Providers Scientifically
Comparing unit prices directly often leads to wrong conclusions. Compare on three dimensions instead:
- Match capability tiers. Only compare models with similar benchmark performance. Pitting a lightweight model’s price against a flagship model’s tells you nothing useful.
- Calculate blended token cost. Weight prices by your real workload’s cache hit rate and input/output ratio, rather than looking at any single unit price.
- Price stability. Limited-time discounts and long-term baseline prices mean different things. Base your budget on baseline prices and treat promotional pricing as a bonus.
The following function computes the blended cost per million output tokens, implementing point two:
def blended_cost(price_hit, price_miss, price_out, hit_rate, in_out_ratio):"""Compute the blended cost (in your currency unit) per million output tokens.price_hit: cached input price per million tokens, must be >= 0price_miss: uncached input price per million tokens, must be >= 0price_out: output price per million tokens, must be >= 0hit_rate: input cache hit rate, between 0 and 1in_out_ratio: input tokens / output tokens, must be > 0"""if not 0 <= hit_rate <= 1:raise ValueError("hit_rate must be between 0 and 1")if in_out_ratio <= 0:raise ValueError("in_out_ratio must be greater than 0")blended_in_price = price_hit * hit_rate + price_miss * (1 - hit_rate)return blended_in_price * in_out_ratio + price_out# Example: promotional prices, hit rate ~66.7%, input/output ratio = 3,000,000 / 30,000 = 100cost = blended_cost(0.25, 3, 6, 2 / 3, 100)print(round(cost, 2)) # 122.67
The return value represents the total input and output cost of generating 1,000,000 output tokens. In the example above, 122.67 divided by 1,000,000 and multiplied by 30,000 gives 3.68, matching the table in Section 3. This confirms the function and the manual calculation use the same methodology, making it useful for reconciling bills.
5. Budgeting with Promotional vs. Baseline Prices
Using the code audit example:
- During the promotion, each audit costs 3.68.
- After the promotion ends and prices revert to standard rates, the same audit costs 14.72.
That is a 4x difference. Build your budget table on baseline prices and count promotional pricing only as a bonus. Before each evaluation, check the following:
- The discount’s expiration date.
- The gap between standard and current prices.
- Whether the cache-hit price is a long-term rate or valid only during the promotion.
- Whether your monthly budget still holds once prices revert.
6. Supply-Side Changes
Some providers may announce new compute hardware plans and signal further price cuts ahead. This is a trend observation, not a firm commitment. Plan based on official announcements, and do not include unfulfilled price cuts in your current budget.
7. Actionable Recommendations for Developers and Enterprises
- Restructure your prompts. Put stable system instructions, tool definitions, and domain knowledge first; put dynamic content last. This requires no code changes yet directly raises your cache hit rate.
- Log token usage per call. Record hit, miss, and output token counts at the gateway layer, generate a monthly cost report, and identify your most expensive business paths.
- Choose models in tiers. Use flagship models for high-value tasks like code audits and architecture analysis; use lightweight models for batch tasks like format conversion and summarization. The price gap can reach an order of magnitude.
- Treat limited-time discounts as validation windows. Complete your proof of concept and establish a cost baseline during the discount period, then decide whether to commit long term.
- Add an abstraction layer. Insert an interface layer between your business code and model APIs so you can switch models or providers easily and avoid vendor lock-in.
