Prompt caching: what a cache hit actually costs

Every article on prompt caching stops at “cached input is about 90% cheaper.” That is true and it is not the number you need. The number you need is: a cache hit costs roughly one fifth of the uncached rate we charge — close to 5× on every model we can check, and 6.25× on gpt-5.6-sol. Whether that is worth restructuring your prompts depends entirely on your hit rate.

In short: A cache hit bills at about 0.1x base input on Anthropic, OpenAI's GPT-5.6 generation and Gemini 2.5+, which works out to roughly 5x cheaper than the uncached realtime rate on six of the seven models we can check (6.25x on gpt-5.6-sol). Where a provider charges a write premium, break-even reuse is (write - read) / (1 - read): 1.28 reads for Anthropic's 5-minute tier, 2.11 for the 1-hour tier. Caching is exact-prefix and all-or-nothing, so a timestamp or reordered tool list in the prefix silently reduces the hit rate to zero.
You need a key before the code below runs. Create an account, generate a key, and copy the base URL (https://aicomp.ai/v1). Create one free →
Check current rates → Free to sign up · $1 minimum top-up · No prepayment
Confirm the key works first. One command, no SDK, costs nothing:
curl https://aicomp.ai/v1/models \
  -H "Authorization: Bearer sk-your-gateway-key"

A JSON list of model IDs means the key is good. Invalid token means it was copied wrong.

The three rates you are actually billed at

Caching replaces one input rate with three. Vendors have converged on the same shape — a read multiplier of 0.1× base input — but they differ on what you pay to create the cache:

Published cache multipliers by vendor, checked September 2026
VendorCache writeCache readWindowMinimum prefix
Anthropic1.25× (5 min) / 2× (1 hr)0.1×5 minutes, refreshed on hit; 1-hour tier opt-in1,024 tokens (Sonnet-class); 4,096 (Haiku 4.5)
OpenAI (GPT-5.6 generation)1.25× explicit0.1×30 minutes, refreshed on reuse1,024 tokens, then 128-token steps
Google Gemini 2.5+ and 3.xStandard input rate; no discounted write tier0.1× (implicit, on by default)1 hour default4,096 (Gemini 3); 2,048 (Gemini 2.5)
DeepSeekNo write charge~0.1×Disk-based, vendor-controlledNot published

Sources: Anthropic prompt caching, OpenAI prompt caching, Gemini caching.

What a hit costs next to what you already pay

This is the comparison nobody publishes, because it needs both rates at once. The last column is the gateway's uncached realtime input divided by the official cache-hit rate — how many times cheaper a hit is than the call you are making today:

What a cache hit costs next to what you already pay — USD per 1M input tokens, rates checked 2026-09-16
Model Official input Cache write
5-minute tier
Cache hit
0.1× list
Gateway realtime
uncached
Gateway ÷ hit
claude-opus-5$5$6.25$0.5$2.55.00×
claude-sonnet-4-6$3$3.75$0.3$1.55.00×
claude-sonnet-5$2$2.5$0.2$15.00×
claude-haiku-4-5-20251001$1$1.25$0.1$0.55.00×
gpt-5.6-sol$4$5$0.4$2.56.25×
gpt-5.6-terra$2$2.5$0.2$15.00×
gpt-5.6-luna$0.2$0.25$0.02$0.15.00×

Cache-hit rates are derived from each vendor's published multiplier, not from gateway billing data — see the note on data sources below.

Two things fall out of it. First, the ratio is remarkably stable: 5.00× on six of the seven models. Second, the one model that breaks the pattern, gpt-5.6-sol, does so because its list rate is promotional rather than standard — see why the same model has two prices for the full table.

Where caching stops paying

If your provider charges a write premium, there is a reuse count below which caching loses money. With a write multiplier w and a read multiplier r, the break-even number of reads per write is:

N = (w - r) / (1 - r)

The practical risk is not the arithmetic, it is expiry. A session that goes quiet longer than the cache window and then wakes up pays a full write on the entire accumulated context, at a rate above plain input. On a 100K-token session that single turn can cost 12–20× a cache hit. If your traffic is bursty rather than continuous, model that cold start before you commit.

What actually breaks the cache

Matching is exact from the first token, and it is all-or-nothing — there is no partial hit that degrades gracefully. The failures are almost always in the prefix, not the model:

The fix is ordering: everything immutable first, a clear breakpoint after the last static block, and conversation history append-only after it.

Marking the breakpoint

import anthropic

client = anthropic.Anthropic()

# 静态前缀(系统提示 / 工具定义 / 参考资料)放前面,
# 动态内容(用户消息、时间戳)一律放后面 —— 顺序错了缓存直接失效。
resp = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    system=[
        {
            "type": "text",
            "text": SYSTEM_PROMPT,          # 长且不变的那一段
            "cache_control": {"type": "ephemeral"},
        }
    ],
    messages=[{"role": "user", "content": user_input}],
)

# usage 里能直接读出命中量 —— 这是唯一可靠的验证方式
print(resp.usage.cache_read_input_tokens, resp.usage.cache_creation_input_tokens)

Read cache_read_input_tokens back rather than assuming a hit. It is the only measurement that survives routing differences across providers.

Where these numbers come from

The gateway catalogue publishes input and output rates only — there is no cached or batch rate in it. So the 0.1×, 1.25× and 2× multipliers above are taken from each vendor's published pricing documentation and checked in September 2026; they are not gateway billing data. We do not know what a cached token bills at through the gateway, because that is not published anywhere. Budget on the two rates you can actually see, and if cache economics are material, measure a direct call and compare it with your gateway invoice for the same workload.

Cost note. Caching is a bet that you will read the prefix more times than the break-even count before the window expires. Workloads that are continuous and prefix-heavy — agents with large tool schemas, RAG over a fixed corpus, long system prompts — win by roughly 5x. Workloads that are bursty or whose prompts vary from the first token win by nothing and pay a write premium for the privilege.

FAQ

How much does prompt caching actually save?

On the models we can cross-check, a cache hit costs about one fifth of what the same uncached input costs through the gateway — the ratio sits at 5.00x on nearly every model and 6.25x on gpt-5.6-sol. The saving is not a fixed percentage of your bill; it is that ratio applied to the share of your input tokens that actually hits the cache.

Is there a point where caching starts costing more?

Yes, when a provider charges a write premium. The break-even reuse count is (w - r) / (1 - r), where w is the write multiplier and r the read multiplier. With Anthropic's 5-minute tier (1.25x write, 0.1x read) it is 1.28 — the second reuse already saves. With the 1-hour tier (2x write) it is 2.11, so you need three reads. Where writes are free there is no threshold at all.

Why is my cache hit rate zero?

Because the prefix is not byte-identical. The usual culprits are a live timestamp or date near the front of the system prompt, a tool list whose order changes between requests, JSON re-serialised with different key ordering, and whitespace injected by a template. Caching is all-or-nothing: one changed character misses entirely.

How long does a cached prefix last?

Anthropic's default is a 5-minute sliding window refreshed on every hit, with an opt-in 1-hour tier. OpenAI's documented window on the GPT-5.6 generation is 30 minutes, refreshed on reuse. Google's implicit cache defaults to an hour. Treat these as the period of guaranteed eligibility, not guaranteed retention.

Does caching work through a gateway?

The gateway catalogue publishes input and output rates only — it does not publish a separate cached rate, so we cannot tell you what a cached token bills at through it. If cache economics are material to your budget, measure cache_read_input_tokens on a direct call and compare against your gateway invoice for the same workload.

What is the minimum prefix length?

Anthropic's minimum varies by model — 1,024 tokens on Sonnet-class models and 4,096 on Haiku 4.5. OpenAI matches from 1,024 tokens in 128-token increments. Google requires 4,096 on Gemini 3 and 2,048 on Gemini 2.5. Shorter prefixes are silently not cached rather than returning an error.

Related

Get API access