Home › Blog › Prompt Caching, Explained

Prompt Caching, Explained

By Victor, founder of apicuts

If your app sends the same long system prompt, tool list or document on every request, you're paying full price to resend it. Prompt caching lets the provider reuse that prefix and bill it at a lower rate.

Quick answer

Put everything that doesn't change at the start of the prompt and everything that changes at the end. OpenAI caches long prefixes automatically, Anthropic caches what you mark with cache_control or automatic caching, and Gemini offers automatic and explicit caching. Check the cached-token count in each response to confirm it works.

How it works

The provider stores the processed start of your prompt. When the next request begins with exactly the same tokens, it reuses that work and bills those tokens at a reduced rate. The match is on the prefix: change anything near the start and everything after it misses the cache.

At each provider

Why caching silently misses

How to check it works

Track the share of input tokens read from cache for each route. On a healthy chat or agent route it should be high and steady. If it drops to zero after a deploy, something at the start of a prompt changed: that's exactly what cost regression protection catches.

Want us to find your 20%?

Book a free 15-minute API cost teardown. Bring last month's provider usage and we'll show you your biggest waste and the first fix we'd ship.

Get My Free 15-Minute API Cost Teardown

Frequently asked questions

Does prompt caching change the model's answers?

No. Caching changes how repeated input is processed and billed, not what the model is asked.

How long does a cache last?

It depends on the provider. Anthropic's default lifetime is five minutes, refreshed on every hit, with a one-hour option. OpenAI clears caches after a short period of inactivity.

Does turning caching on cost extra?

OpenAI's automatic caching costs nothing extra. Anthropic charges a premium to write the cache, which pays off from the second request that reuses it.

Related