المشاركات

Prompt Caching Explained

How prompt caching works, why cached reads cost up to 98% less than fresh input, and how cache writes and TTLs change your monthly bill.
Onsp
Bar chart showing how much cheaper cached input is than fresh input: DeepSeek V4.1 Flash is 98 percent cheaper, Anthropic and OpenAI 90 percent, Grok 4.6 75 percent

Prompt caching lets a provider reuse work it has already done. When you send a request whose opening tokens exactly match a prefix the provider has processed recently, it skips that portion and bills the reused tokens at a cache-read rate instead of the full input rate. For applications with long system prompts, fixed schemas or repeated document context, this is the largest single lever on API spend.

How much cheaper is a cache read

The discount differs sharply by provider. The table below shows the cache-read price against the fresh input price for every model in the dataset that publishes one.

ModelInputCached inputDiscountCache write
DeepSeek V4.1 Flash$0.30$0.006098%—
Claude Fable 5.1$10.00$0.2597.5%$12.50
DeepSeek V4 Pro$1.32$0.0496.7%—
GPT-6.1 Sol$2.00$0.1095%$2.50
GPT-6 Astra$10.00$1.0090%$12.50
GPT-6 Sol$2.00$0.2090%$2.50
GPT-6 Luna$0.10$0.0190%$0.13
GPT-5.6 Sol$4.00$0.4090%$5.00
GPT-5.6 Terra$2.00$0.2090%$2.50
GPT-5.6 Luna$0.20$0.0290%$0.25
GPT-5.5$5.00$0.5090%—
GPT-5.4$2.50$0.2590%—
GPT-5.4 mini$0.75$0.0790%—
GPT-5.4 nano$0.20$0.0290%—
GPT-5.2$1.75$0.1790%—
Claude Opus 5$5.00$0.5090%$6.25
Claude Sonnet 5$2.00$0.2090%$2.50
Claude Sonnet 4.6$3.00$0.3090%$3.75
Claude Haiku 4.5$1.00$0.1090%$1.25
Gemini 3.8 Flash$0.75$0.0790%—
Gemini 3.7 Flash$0.75$0.0790%—
Gemini 3.5 Flash-Lite$0.30$0.0390%—
Gemini 3.5 Flash$1.50$0.1590%—
Gemini 3.1 Pro (Preview)$2.00$0.2090%—
Gemini 2.5 Pro$1.25$0.1390%—
Grok 4.3$1.25$0.2084%—
GPT-4.1$2.00$0.5075%—
Grok 4.6$2.00$0.5075%—

The standout is DeepSeek V4.1 Flash, where a cache read costs 98% less than fresh input. Anthropic and Google sit around the 90% mark. Grok is shallower, at 75% and 84%.

The write premium changes the break-even

A cache is not free to create. Anthropic charges 1.25x the normal input rate to write a cache entry — visible above as $2.50 against a $2.00 input price. That surcharge is paid once per cache lifetime. Every subsequent read is discounted.

So the break-even is: how many requests will reuse this prefix before the cache expires? If a prefix costs $1.25 to write and saves $0.90 per million tokens on each of twenty subsequent requests, it pays for itself many times over. If only one request will ever use it, caching costs you 25% more than not caching.

What breaks a cache

Caching matches on an exact token prefix. Anything that changes early in the prompt invalidates everything after it. The common offenders are a timestamp at the top of the system prompt, a request ID injected before the instructions, a user name interpolated into the opening line, or a tool schema whose property order is not deterministic.

The fix is structural, not clever. Put stable material first — role instructions, output schema, reference documents — and volatile material last: the user's question, the current date, the session context. If you need the date for reasoning, pass it as a late message rather than a system-prompt prefix.

Where caching does not help

Short prompts. If your entire request is 300 tokens of unique user input, there is nothing stable to cache and the write premium is pure loss. Caching pays when the reusable prefix is long relative to the variable suffix — typically above roughly a thousand tokens of stable context.

Low-frequency traffic also erodes the benefit. A cache that expires in minutes only helps if requests arrive within that window. A batch job that runs once a night will rarely hit a cache written the previous night.

Measure the hit rate before and after

Providers report cached token counts in the usage object of each response. Log that number alongside total input tokens and compute the ratio. Without it you cannot tell whether caching is helping or quietly adding write charges. The calculator models both scenarios side by side using the cache prices in the table above.

Related reading

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.