Skip to content
CodexPal
AI Tools & Comparisons · Intermediate · 3 min read

Prompt caching explained: when it cuts your AI bill and when it doesn’t

Cached input can cost a small fraction of normal input. Here is how OpenAI, Claude, Gemini and DeepSeek price caching, the break-even logic and how to structure prompts for it.

By CodexPal Editorial3 min read
A long prompt split into a stored, reused prefix and a short new message.

Many applications send the same long beginning with every request: instructions, a product catalogue, a policy document or a codebase summary. Prompt caching lets the provider keep that prefix and bill reuse at a reduced rate. The saving can be large, but the rules differ by provider.

How providers price cached input

Each provider lists a separate, lower rate for input served from cache. The size of the discount and the extra charges vary.

ProviderExampleStandard inputCached inputExtra charges
OpenAIGPT-6.1 Sol$2.00$0.10None listed for cache reads
AnthropicClaude Sonnet 5.5$2.00$0.10Cache writes: $2.50 (5 min) or $4.00 (1 hour)
GoogleGemini 3.1 Pro (preview)$2.00$0.20Storage: $4.50 per 1M tokens per hour
DeepSeekDeepSeek Flash (peak)$0.30$0.006Cache hit vs miss pricing

The break-even logic

With Anthropic’s 5-minute cache, writing a prefix costs 1.25 times normal input, and each later hit on Sonnet 5.5 costs 0.05 times. The first write adds 0.25 of the prefix price; the first reuse saves 0.95. Caching pays for itself as soon as the prefix is reused once within the cache lifetime.

The risk is a prefix that is written but rarely read: low-traffic features, prompts that change slightly on every request, or long gaps between requests that let the cache expire. Google’s hourly storage charge means a large cached context that sits idle still costs money.

Structure prompts so they can be cached

Caching works on an exact, unchanged prefix. Put stable content first: system instructions, tool definitions, reference documents and examples. Put anything that changes, such as the user’s message, the date or retrieved passages, after it.

A single changed character early in the prompt, like a timestamp in the system prompt, breaks the match for everything after it. Move dynamic values to the end.

A cache-friendly prompt

  1. 01StableInstructions and tool definitions
  2. 02StableReference documents and examples
  3. 03ChangesRetrieved passages and history
  4. 04ChangesThe user’s new message
Only the unchanged prefix is eligible for the cached rate.

Measure the hit rate

API responses report cached and uncached input tokens separately. Log them per feature and calculate the share of input served from cache. That figure is the “cache share” input in our calculator.

If the hit rate is low, look for dynamic content near the start of the prompt, and check whether traffic is frequent enough to keep the cache warm.

Open the AI API cost calculator →

The takeaway

Prompt caching is one of the most effective ways to lower input costs for repeated context. Keep stable content first, measure the hit rate and include write and storage charges in your estimate.

Go to the source

Sources & further reading

Primary references checked on November 12, 2026. Examples and diagrams are illustrative unless stated otherwise.

  1. Anthropic — Claude API pricing
  2. OpenAI — API pricing
  3. Google — Gemini API pricing
  4. DeepSeek — API models and pricing
  5. Anthropic — prompt caching
Found this useful? Pass it along.