Prompt caching lowers AI API costs by storing the precomputed attention state of repeated prompt prefixes, such as system instructions, tool schemas, and reference documents, so the model skips reprocessing those tokens on later calls. Because providers avoid repeating expensive prefill work, they discount cached input tokens by 90% to 97.5% as of 2026 while cutting response latency.
ContentsToggle
Why repeated prompts inflate your AI API bill
Every large language model API request runs in two distinct phases: prefill and decode. During prefill, the model reads your entire input prompt at once to calculate internal key-value (KV) attention tensors, and during decode it generates output tokens one by one.
Computing self-attention during prefill scales quadratically with the length of your input prompt, while loading precomputed KV attention states from memory scales linearly, according to a 2024 MLSys systems paper. If your app runs a multi-turn coding agent or document analyzer, sending the same 10,000-token system prompt and tool list on every turn forces the server to repeat that heavy prefill math from scratch.
Prompt caching keeps those computed KV tensors alive in fast server memory or durable cache storage for a set time window. When your next request starts with the exact same sequence of tokens, the provider loads the saved state directly and only runs full prefill on the new tokens appended at the end.
The financial impact shows up fast in real workloads. In a January 2026 study titled “An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks,” researchers tested more than 500 multi-turn agent sessions with 10,000-token system prompts across OpenAI, Anthropic, and Google on DeepResearchBench. Across providers, the multi-provider agent benchmark measured 41% to 80% lower total API costs and 13% to 31% faster Time to First Token (TTFT).
How prompt caching pricing and break-even math work
API providers split input billing into three buckets: standard uncached input tokens, discounted cache read tokens, and, on explicit or extended-retention tiers, upfront cache write tokens. When a provider charges a write fee, you pay a small premium on the first request so every follow-up hit costs a fraction of normal input pricing.
On Anthropic’s Claude API as of 2026, standard cache writes cost 1.25 times the base input price for a 5-minute time to live (TTL), or 2 times the base price for a 1-hour TTL. Cache reads drop to 0.1 times base input (90% off) on standard tiers, 0.05 times (95% off) on Claude Opus 5.5 and Sonnet 5.5, and 0.025 times (97.5% off) on Claude Fable 5.2 and Mythos 5.2, according to the Claude prompt caching documentation.

In plain dollars as of 2026, uncached input on Claude Opus 5.5 runs $4.00 per million tokens, while a cache read costs $0.20 per million tokens. On OpenAI’s API as of 2026, standard input on gpt-6.2-sol drops from $2.00 to $0.10 per million tokens on cached reads (95% off), and gpt-6.2-astra drops from $8.00 to $0.40 per million tokens, with 30-minute writes billed at $2.50 and $10.00 per million tokens respectively and 12-hour writes on gpt-6.2-astra at $20.00 per million tokens.
When a 1.25x write premium applies, the upfront fee typically pays for itself by the second or third cache hit. Because model prices and retention tiers shift frequently, always check each provider’s live pricing page before locking in production budgets.
How major AI API providers compare on prompt caching
Each cloud and model provider sets its own minimum prefix length, activation method, and cache expiration window. The table below summarizes verified specifications as of 2026 across OpenAI, Anthropic, Google, and Amazon Bedrock.
| Provider | Activation method | Minimum prefix length | Cache read discount | Default and extended TTL |
|---|---|---|---|---|
| OpenAI API | Automatic prefix matching | 1,024 tokens on GPT-5.6 and later (128-token increments) | Up to 95% off on flagship models | 5 to 10 minutes inactive (in_memory); up to 24 hours (24h) |
| Anthropic Claude API | Opt-in via top-level or block-level cache_control | 512 to 4,096 tokens depending on model | 90% standard; 95% on Opus/Sonnet 5.5; 97.5% on Fable/Mythos 5.2 | 5 minutes default (refreshed on hits); 1 hour extended |
| Google Gemini API | Implicit automatic caching (exclusive on Gemini 4 and Interactions API) | 4,096 tokens for applicable models | 90% on Standard/Priority; up to 95% on supported models | Best-effort durable storage up to 12 hours from creation |
| Amazon Bedrock | Implicit or explicit depending on model | 1,024 tokens per breakpoint standard; down to 256 tokens on Kimi K3 | Up to 90% off cached tokens | 30-minute minimum TTL for explicit caching on supported models |
Google’s implicit caching on Gemini 4 models and the Interactions API requires zero setup calls and charges zero storage fees, as detailed in the Gemini API caching guide. OpenAI also skips write fees on its default in_memory cache, while charging write multipliers only when you select extended 30-minute or 12-hour retention tiers.
Minimum token thresholds matter more than most teams expect. On Anthropic’s platform as of 2026, Claude Fable 5.2 caches prefixes starting at 512 tokens, standard models start at 1,024 tokens, Claude Opus 4.7 and Mythos Preview require 2,048 tokens, and higher tiers require 4,096 tokens.
How to set up prompt caching and fix cache misses
Positional encoding inside transformers makes every KV tensor depend on the exact position of the tokens that came before it. Even a one-character change near the start of your prompt invalidates the entire cached prefix from that point onward, so prompt structure determines whether you save money or pay full price.
- Order your prompt strictly from most static to most dynamic. Place system instructions, tool schemas, and unchanging reference files at the very start, followed by conversation history, and put the user’s current query and runtime metadata at the very end.
- Verify your static prefix clears the model’s minimum token threshold. Pad or consolidate shared context so the unchanging block stays above 1,024 tokens on OpenAI GPT-5.6+ and standard Claude models, or 4,096 tokens on applicable Gemini models.
- Configure provider-specific parameters where required. On Anthropic, send a top-level cache_control field set to {“type”: “ephemeral”} for automatic 5-minute caching, add “ttl”: “1h” for 1-hour retention, or attach cache_control to individual static blocks. On OpenAI, caching activates automatically, and you can optionally set prompt_cache_retention to “in_memory” or “24h” (and pass prompt_cache_key only on pre-GPT-5.6 routing or when you need isolated per-customer accounting), as covered in the OpenAI prompt caching guide. On Gemini 4 and the Interactions API, send identical prefixes without making separate cache creation calls.
- Inspect response telemetry on every deployment. Check usage.input_tokens_details.cached_tokens on OpenAI responses or the cache read and write token counters in Anthropic’s usage payload to confirm hits are actually registering.
If your cached token counter reads zero or stays below 20% on a steady workload, check four common failure points right away. First, strip ISO timestamps, session UUIDs, user names, and randomly sorted JSON tool keys out of the top of your system prompt, because any variance at token zero breaks prefix matching.
Second, check whether long idle gaps between requests are letting short caches expire. If your traffic arrives more than 5 to 10 minutes apart, default in-memory caches evict before the next call; switch to Anthropic’s 1-hour TTL or OpenAI’s 24h retention setting if the request frequency justifies the higher write multiplier.
Third, avoid blindly placing explicit cache breakpoints around volatile, single-use tool outputs. In the 2026 multi-provider agent benchmark, naive full-context caching often paid write overhead on one-off tool results that were never reused, stalling or worsening latency compared with caching only the stable system prompt. Fourth, on OpenAI GPT-5.6 and later, omit prompt_cache_key unless you specifically need separate customer accounting, because arbitrary keys can fragment cache routing.
Frequently asked questions
Does prompt caching lower model quality or change answers?
No. Because causal transformer attention at any token position only looks at earlier tokens, reusing a precomputed KV cache for an identical prefix on the same model weights and numeric precision produces token-exact identical outputs under greedy decoding compared with recomputing the prompt from scratch.
Does prompt caching discount generated output tokens?
No. Prompt caching applies only to repeated input tokens processed during the prefill phase, so every generated output token is billed at the model’s full standard output rate.
Do cached tokens still count against the model’s context window?
Yes. Caching cuts the cost and prefill latency of repeated input prefixes, not the size of the prompt itself, so cached tokens still occupy space in the model’s maximum context window.

