Cost guide
Prompt Caching Cost Savings Guide: Cut LLM API Bills by 75-90%
· · Estimated read: 7 min
Prompt caching stores repeated input prefixes on the provider's servers, reducing the effective input cost by 75-90% for cached tokens. This guide explains how caching works across major providers, quantifies savings with real model data, and shows best practices for maximizing cache hit rates.
1. How Prompt Caching Works
When you send a request to an LLM API, the provider processes your input tokens. With prompt caching, the provider stores the initial prefix of your input (system prompt, few-shot examples, documents) on its servers. If the next request starts with the same prefix, the provider skips reprocessing those tokens and charges a lower cached-input rate.
The key constraint is exact prefix matching: the cached tokens must appear at the start of the prompt in the same order. Variations in system prompts, different document ordering, or even whitespace changes will miss the cache.
Pricing structure
Most providers use a three-tier pricing model for cached workloads:
- Standard input — the normal per-token rate for non-cached input
- Cached input — a discounted rate (typically 10-25% of standard) for tokens that hit the cache
- Cache write — an optional premium charged on the first request that populates the cache (some providers charge nothing extra)
Output tokens are always billed at the standard rate regardless of caching.
2. Provider Caching Comparison
Caching behavior and pricing vary by provider. Here is how the major providers compare:
| Provider | Cached discount | Cache write fee | Cache TTL | Min prefix size |
|---|---|---|---|---|
| OpenAI | 50-90% off input | GPT-5.6+: 1.25× input; earlier models: no separate write premium | GPT-5.6+: at least 30 min after write/reuse; earlier models vary by retention mode | 1,024 tokens (GPT-4o), 128k (o3) |
| Anthropic | 90% off input | 5 min writes: 1.25× input; 1 hr writes: 2× input | 5 min default; optional 1 hr TTL | 2,048 tokens (Claude 3+), 1,024 (Haiku) |
| Google Gemini | 75-90% off input | No separate write premium; explicit caches add token-hour storage cost | Implicit: provider-managed; explicit: configurable, 1 hr default | 32 tokens |
| DeepSeek | 90% off input | None | ~5 min | Not published |
| xAI | 75-90% off input | None | ~5 min | Not published |
The table below shows 997 models with cached input pricing across 40 providers in our catalog. Use the compare page to inspect cached pricing rows side by side.
3. Which Models Support Caching
The following table shows representative models from each major provider that support cached input pricing. For the full list, filter by "cached input" on the compare page.
| Provider | Model | Input $/1M | Cached $/1M | Output $/1M | Cache savings | Context |
|---|---|---|---|---|---|---|
| OpenAI | gpt-4o | $$2.50 | $$1.25 | $$10.00 | 50% | 16,384 |
| OpenAI | gpt-4o-mini | $$0.150 | $$0.075 | $$0.600 | 50% | 16,384 |
| OpenAI | GPT-4.1 | $$2.00 | $$0.500 | $$8.00 | 75% | 32,768 |
| OpenAI | GPT-4.1 mini | $$0.400 | $$0.100 | $$1.60 | 75% | 32,768 |
| OpenAI | gpt-4.1-nano | $$0.100 | $$0.025 | $$0.400 | 75% | 32,768 |
| OpenAI | o3 | $$2.00 | $$0.500 | $$8.00 | 75% | 100,000 |
| OpenAI | o4-mini | $$1.10 | $$0.275 | $$4.40 | 75% | 100,000 |
| Anthropic | Claude Sonnet 4 | $$3.00 | $$0.300 | $$15.00 | 90% | 64,000 |
| Anthropic | claude-sonnet-4-5-20250929 | $$3.00 | $$0.300 | $$15.00 | 90% | 64,000 |
| Anthropic | claude-haiku-4-5 | $$1.00 | $$0.100 | $$5.00 | 90% | 64,000 |
| Anthropic | claude-3-7-sonnet-20250219 | $$3.00 | $$0.300 | $$15.00 | 90% | 64,000 |
| Gemini 2.5 Flash | $$0.300 | $$0.030 | $$2.50 | 90% | 65,535 | |
| gemini-2.5-pro | $$1.25 | $$0.125 | $$10.00 | 90% | 65,535 | |
| gemini-2.0-flash | $$0.100 | $$0.025 | $$0.400 | 75% | 8,192 | |
| DeepSeek | DeepSeek Chat | $$0.280 | $$0.028 | $$0.420 | 90% | 8,192 |
| DeepSeek | deepseek-reasoner | $$0.280 | $$0.028 | $$0.420 | 90% | 65,536 |
| xAI | grok-4.5 | $$2.00 | $$0.300 | $$6.00 | 85% | 500,000 |
4. Quantified Savings Examples
The real savings from caching depend on your cache hit rate — the percentage of requests where the input prefix matches the cached version. Here are concrete examples at different hit rates.
Scenario: 10k input tokens, 1k output tokens, 10,000 requests/month
This represents a typical RAG workload where the system prompt and retrieved context stay consistent across requests.
| Model | Strategy | Monthly cost | Savings vs no cache |
|---|---|---|---|
| GPT-4o | No caching | $350.00 | — |
| 50% cache hit | $287.50 | -18% | |
| 80% cache hit | $250.00 | -29% | |
| Claude Sonnet 4 | No caching | $450.00 | — |
| 50% cache hit | $315.00 | -30% | |
| 80% cache hit | $234.00 | -48% | |
| Gemini 2.5 Flash | No caching | $55.00 | — |
| 50% cache hit | $41.50 | -25% | |
| 80% cache hit | $33.40 | -39% | |
| DeepSeek Chat | No caching | $32.20 | — |
| 50% cache hit | $19.60 | -39% | |
| 80% cache hit | $12.04 | -63% |
At an 80% cache hit rate, input costs drop by 72-90% depending on the provider. The savings are most dramatic for workloads with large system prompts or repeated document context.
5. Cost Scenarios: Cached vs Non-Cached Workloads
These three scenarios model real-world workloads where caching delivers measurable savings. Each uses the cache reuse preset from the calculator as a starting point.
Customer support chatbot
10k input tokens (system prompt + history), 500 output tokens, 50k requests/month, 70% cache hit rate
| Model | Without cache | With cache (70% hit rate) | Monthly savings |
|---|---|---|---|
| gpt-4o (OpenAI) | $1500.00 | $1062.50 | $437.50 saved |
| Claude Sonnet 4 (Anthropic) | $1875.00 | $930.00 | $945.00 saved |
| Gemini 2.5 Flash (Google) | $212.50 | $118.00 | $94.50 saved |
| DeepSeek Chat (DeepSeek) | $150.50 | $62.30 | $88.20 saved |
RAG with long system context
8k input tokens (system + retrieved docs), 1k output tokens, 20k requests/month, 60% cache hit rate
| Model | Without cache | With cache (60% hit rate) | Monthly savings |
|---|---|---|---|
| gpt-4o (OpenAI) | $600.00 | $480.00 | $120.00 saved |
| Claude Sonnet 4 (Anthropic) | $780.00 | $520.80 | $259.20 saved |
| Gemini 2.5 Flash (Google) | $98.00 | $72.08 | $25.92 saved |
| DeepSeek Chat (DeepSeek) | $53.20 | $29.01 | $24.19 saved |
Agentic coding workflow
15k input tokens (code + instructions), 2k output tokens, 10k requests/month, 80% cache hit rate
| Model | Without cache | With cache (80% hit rate) | Monthly savings |
|---|---|---|---|
| gpt-4o (OpenAI) | $575.00 | $425.00 | $150.00 saved |
| Claude Sonnet 4 (Anthropic) | $750.00 | $426.00 | $324.00 saved |
| Gemini 2.5 Flash (Google) | $95.00 | $62.60 | $32.40 saved |
| DeepSeek Chat (DeepSeek) | $50.40 | $20.16 | $30.24 saved |
Key insight
Caching does not reduce output costs — and output tokens are typically 3-4x more expensive than input tokens. The savings come entirely from the input side. For workloads where output dominates (long-form generation, reasoning), caching has less impact. For workloads where input dominates (RAG, classification with long contexts), caching is the single highest-leverage optimization.
6. Best Practices for Cache Optimization
Structure prompts for prefix stability
Place static content (system instructions, few-shot examples, reference documents) at the beginning of the prompt. Put variable content (user queries, conversation history) at the end. This maximizes the shared prefix across requests.
Minimize prefix variations
Avoid dynamic system prompts that change per request (timestamps, session IDs, random instructions). If you need dynamic elements, place them after the static prefix rather than before it.
Keep the cached prefix large enough
Each provider has a minimum prefix size for caching. OpenAI requires at least 1,024 tokens for GPT-4o models. Anthropic requires 2,048 tokens for Claude 3+. Google Gemini starts caching at just 32 tokens. Short prompts may not benefit from caching at all.
Monitor cache hit rates
OpenAI and Anthropic report cached tokens in their usage responses. Track this metric to understand your actual hit rate. If it is below 30%, the caching overhead may not be worth the implementation effort.
Account for cache TTL
Cache lifetime varies by provider and model. Treat the documented or configured TTL as a workload constraint, and remember that reuse can refresh some providers' entries. Low-traffic workloads may still lose reuse between requests, while clustered requests are more likely to stay within the active cache window.
Combine with model routing
Use a model routing cascade with caching: route simple queries to a budget model and complex queries to a premium model. Both routes benefit from cached system prompts, compounding the savings.
7. Frequently Asked Questions
How does prompt caching work?
Prompt caching stores a prefix of your input tokens on the provider's servers. When the same prefix appears in subsequent requests, the provider charges a lower cached-input rate instead of the standard input rate. The prefix must match exactly — same tokens in the same order — from the start of the prompt.
How much can prompt caching save?
Most providers offer 75-90% savings on cached input tokens. For example, Anthropic charges $0.30/M cached input vs $3.00/M standard for Claude Sonnet 4 (90% savings). OpenAI charges $0.50/M cached vs $2.50/M for GPT-4o (80% savings). The exact discount depends on the provider and model.
Is there a cost for writing to the cache?
Cache-write billing depends on the provider and model. Anthropic charges 1.25× base input for 5-minute cache writes and 2× for 1-hour writes. OpenAI GPT-5.6 and later charges 1.25× the uncached input rate for cache writes, while earlier OpenAI prompt-caching models do not add a separate write premium. Google Gemini explicit caching does not use a separate write premium, but it adds cache-storage charges based on cached token volume and retention time.
Which models support prompt caching?
Over 1,100 models across 30+ providers support cached input pricing in our catalog. Major providers include OpenAI (100+ models), Anthropic (23 models), Google Gemini (50+ models), DeepSeek (12 models), xAI (38 models), and Mistral via Azure. Check each model's pricing page for cached-input rows.
Does prompt caching affect output quality?
No. Cached prompts produce identical output to non-cached prompts. The cache only affects how input tokens are billed — the model processes the same tokens either way.
How long does the cache last?
Cache lifetime varies by provider and model. OpenAI GPT-5.6 and later uses a 30-minute minimum/default TTL that refreshes after a write or reuse; earlier OpenAI models use different retention modes, including short in-memory retention and supported extended retention. Anthropic uses a 5-minute default TTL and offers a 1-hour option; cache hits refresh the entry without another write charge. Gemini implicit caching is provider-managed, while explicit cached-content objects use a configurable TTL that defaults to 1 hour. When an entry is no longer reusable, the next eligible request must establish cacheable content again under that provider's rules.
Can I use caching with streaming?
Yes. Prompt caching works with both streaming and non-streaming responses. The cache applies to the input tokens regardless of how the output is delivered.
When should I not use prompt caching?
Caching provides minimal benefit when every request has a unique prompt (no repeated prefix), when input tokens are very short (under 1k tokens), or when the cache-hit rate is expected to be below 20%. In these cases, standard input pricing is sufficient.
Estimate your caching savings
Use the calculator with cache reuse preset to model your exact workload and see how much caching saves.
Pricing data sourced from our catalog. Check data sources for provenance and freshness.