PromptCostLab guides
Cost optimization

How prompt caching changes cost

Prompt caching can cut input costs by half or more on repetitive workloads — if you structure prompts for it. Here is how every major provider prices cache reads and writes, verified August 2026.

What prompt caching means

Many AI workflows send the same system instructions, policy text, examples, or document prefix repeatedly. When a provider supports prompt caching, the repeated portion is stored after first processing and served from cache on later requests — billed at a fraction of the fresh-input price and returned faster.

Caching behavior, minimum sizes, lifetimes, and pricing vary by provider and model. Treat the provider documentation and the returned usage fields as authoritative for billing.

Cache prices at every provider (August 2026)

Cache reads are dramatically cheaper than fresh input everywhere — but the details differ:

  • Anthropic: reads at 10% of input; 5-minute cache writes cost 1.25× input, 1-hour writes 2×. Requires explicit cache_control markers.
  • OpenAI: automatic for stable prefixes of 1,024+ tokens; reads at 10%, writes at 1.25× input. Cache lasts 5–10 minutes, refreshed on use.
  • Google Gemini: implicit caching gives ~10% reads automatically; explicit caches add hourly storage ($4.50/1M tokens/hr on 3.1 Pro, $0.50–$1.00 on Flash) with a 4,096-token minimum.
  • xAI (Grok): automatic; reads at $0.30 (Grok 4.5) or $0.50 (Grok 4.6) — 15–25% of input. No write fee; 5–15 minute TTL.
  • DeepSeek: automatic disk cache; hits at $0.003625 per million on V4 Pro — about 1/120th of fresh input, with caches lasting hours.
  • Moonshot (Kimi): automatic; reads at 10% of input ($0.30 on K3).
  • Mistral: cached input at 90% off ($0.05 on Large 3).

Build a stable prefix

Caches match the longest unchanged prefix of a request. Place reusable instructions and shared context before rapidly changing user content; put timestamps, random IDs, and per-user data at the end. One changed character near the top prevents a match on everything after it — the classic silent budget leak.

  • Keep system instructions and tool schemas byte-identical across requests.
  • Order examples and retrieved documents deterministically.
  • Separate stable context from user-specific data.
  • Track cache-read and cache-creation tokens in the provider usage fields.

The math: when caching pays

Consider a support assistant on Claude Sonnet 5 ($2/$10 per million) with a stable 8,000-token prefix, called 50,000 times a month at a 90% hit rate. Uncached, the prefix costs $800 across the month. With caching: reads cost $72, plus the initial writes at 1.25× ($2.50/1M) on misses — roughly $110 total. That structural decision saves ~$690/month, or 86% of the prefix cost.

The break-even is generous: on Anthropic and OpenAI, a prefix read more than twice already covers its 1.25× write cost. Workloads with a unique prompt on every call see no benefit, and very short prompts may not qualify (OpenAI's 1,024-token minimum; Gemini's 4,096).

When caching does not help

Short requests may not qualify or save too little to justify added complexity. Workloads with unique context on every call have limited reuse. High-frequency traffic with idle gaps longer than the TTL (5–15 minutes on several providers) can see hit rates collapse — though DeepSeek's disk cache and Anthropic's 1-hour option exist exactly for that case.

Calculate savings from your actual hit rate, not the theoretical maximum: a 40% real hit rate saves far less than an assumed 90%.

Measure total task cost

Compare uncached input, cache creation, cache reads, output, retries, and request volume together. A cheaper cached prefix is valuable only if the workflow still produces reliable answers. Monitor cost per completed task alongside token-level metrics — and run your numbers through the prompt caching calculator, which applies each provider's real read/write/TTL pricing.

Frequently asked questions

What is a cache read cost?

The per-token price for input served from a prompt cache instead of being processed fresh — typically 10% of the input price at Anthropic, OpenAI, and Kimi, 15–25% at xAI, 90% off at Mistral, and about 1/120th of input at DeepSeek.

Does prompt caching cost extra?

At providers that bill cache writes, the first processing of a cached prefix costs more than normal input: 1.25× at OpenAI and Anthropic (5-minute TTL), 2× for Anthropic's 1-hour cache. Gemini charges hourly storage for explicit caches instead. xAI, DeepSeek, and Kimi charge no write fee.

How do I enable prompt caching?

It is automatic at OpenAI (1,024+ token stable prefixes), xAI, DeepSeek, Kimi, and Gemini implicit caching. Anthropic requires adding cache_control markers to the request. The design principle is the same everywhere: stable content first, variable content last.

How much does prompt caching save?

Depends on hit rate and prefix share, but repetitive workloads commonly cut total bills 40–70%. At a 90% hit rate on a large stable prefix, input costs drop by roughly 86% after write fees.

Measure a real prompt.Use PromptCostLab to count tokens with a real tokenizer, check context pressure, and estimate API cost privately.Open the prompt calculator →