← Back to Blog

What Is Prompt Caching? How DeepSeek, Claude, and GPT Cache Hits Cut Your API Bill by 90%

By Eric Bush · July 16, 2026 · 6 min read

Abstract circuit board with glowing nodes representing cached data pathways in AI systems

What Is Prompt Caching?

If you're making repeated API calls to large language models with similar prompts — system instructions, few-shot examples, or long context documents — you're paying full price every single time those tokens get processed. Prompt caching (sometimes called prefill caching or KV-cache reuse) changes that equation dramatically.

When you send a prompt to an LLM, the model computes internal key-value (KV) attention states for every input token. Prompt caching stores these computed states so that when the same prefix appears in a subsequent request, the provider skips the expensive recomputation. You get faster time-to-first-token and, more importantly, a significant cost reduction on those cached input tokens.

For developers running production AI applications — chatbots, coding assistants, RAG pipelines, or batch processing — prompt caching is one of the highest-impact optimizations available today. The savings can reach 90% on input token costs with zero impact on output quality.

How Each Provider Implements Prompt Caching

Every major AI provider now offers some form of prompt caching, but the implementations differ significantly in terms of discount depth, automation, and requirements. Here's how they compare:

Provider Discount Rate Cache TTL Requirements
Anthropic (Claude) 90% off cached tokens 5 minutes (refreshed on hit) Explicit cache_control breakpoints; min 1,024 tokens
DeepSeek V4 90% off (1/10th price) Auto-managed Automatic for repeated prefixes; no code changes needed
OpenAI (GPT) 50% off cached tokens 5-10 minutes Automatic; min 1,024 tokens; prefix matching
Google Gemini Reduced per-token rate Configurable (min 1 min) Explicit context caching API; min 32,768 tokens

Anthropic Claude: The Deepest Discount

Anthropic offers the most aggressive caching discount at 90% off cached input tokens. To use it, you add cache_control breakpoints in your messages to mark where cacheable content ends. The system caches everything up to that breakpoint.

The cache has a 5-minute TTL that refreshes every time a cache hit occurs, making it ideal for multi-turn conversations where the system prompt and conversation history remain stable. There's a small write cost (25% premium on the first request that populates the cache), but subsequent hits at 10% of normal price quickly offset this.

Best for: Applications with long system prompts, multi-turn conversations, and document Q&A where the same context is queried repeatedly.

DeepSeek V4: Automatic and Aggressive

DeepSeek recently reduced their cache hit pricing to 1/10th of the original input cost across all models — matching Anthropic's 90% discount rate. The key advantage: it's fully automatic. DeepSeek detects repeated prefixes and caches them without any code changes on your end.

This makes DeepSeek particularly attractive for developers who want caching benefits without modifying their API integration. Combined with their already competitive base pricing, the effective per-token cost with cache hits is exceptionally low.

Best for: Cost-sensitive applications, batch processing workloads, and teams that want zero-friction caching without API changes.

OpenAI GPT: Automatic but Shallower Savings

OpenAI implemented automatic prompt caching that requires no code changes. Any request with a prefix of at least 1,024 tokens that matches a previous request will receive 50% off the cached portion. The cache TTL ranges from 5 to 10 minutes depending on traffic.

While the 50% discount is less dramatic than Claude's or DeepSeek's 90%, the zero-effort implementation means many developers are already benefiting without realizing it. Check your API usage dashboard — you may already see cached token entries.

Best for: Teams already on OpenAI that want passive savings without migration or code changes.

Google Gemini: Explicit but Flexible

Google's context caching for Gemini requires the most setup. You explicitly create a cached content resource via the API, set a TTL (minimum 1 minute), and reference it in subsequent requests. The minimum cacheable content is 32,768 tokens — much higher than other providers.

The trade-off is flexibility: you have precise control over what's cached, how long it persists, and you can even update cached content. There's a storage cost per hour for maintaining the cache, so it's most economical for high-volume use cases.

Best for: Applications with very long context (entire codebases, book-length documents) that receive many queries against the same content.

Practical Tips to Maximize Cache Hit Rates

Regardless of which provider you use, these strategies will help you get the most out of prompt caching:

1. Front-load static content. Place your system prompt, instructions, and reference documents at the beginning of each request. Caching matches from the start of the prompt forward — any divergence early in the sequence breaks the cache match for everything after it.

2. Avoid randomizing prompt structures. If you shuffle few-shot examples, randomize tool definitions, or inject timestamps into your system prompt, every request looks unique to the cache. Keep static content deterministic and identical across requests.

3. Batch similar requests together. If you have multiple queries against the same context, send them in close succession. Cache TTLs are typically 5-10 minutes, so bunching requests ensures the cache stays warm.

4. Meet minimum token thresholds. Most providers require at least 1,024 tokens for caching to activate. If your system prompt is shorter, consider adding structured context (tool definitions, output schemas) to reach the threshold.

5. Monitor your cache metrics. All providers report cache hit/miss statistics in their API responses or dashboards. Track your hit rate and adjust your prompt architecture if it's below 70-80%.

6. Use caching-aware architectures. Design your application so that the cacheable prefix (system prompt + context) is separated from the variable suffix (user query). This clean separation makes cache hits predictable and consistent.

Real-World Savings Example

Consider a coding assistant that sends a 4,000-token system prompt with every request. At 1,000 requests per day using Claude (Sonnet), without caching you'd pay full input price on 4 million tokens daily. With prompt caching and a 90% hit rate, roughly 3.6 million of those tokens are cached — saving 90% on those tokens. That's a reduction from the full input cost to approximately 13% of original spend on those prefixed tokens alone.

Multiply this across thousands of daily users and the savings compound into thousands of dollars per month. For high-volume applications, prompt caching isn't optional — it's essential infrastructure.

Which Provider Should You Choose for Caching?

If maximum savings are your priority and you don't mind explicit cache annotations, Anthropic Claude's 90% discount is hard to beat. If you want the same 90% discount without any code changes, DeepSeek V4 offers the best zero-friction experience. If you're already on OpenAI and don't want to migrate, the automatic 50% savings require zero effort. And if you're working with very large contexts and need precise cache control, Google Gemini's explicit approach gives you the most flexibility.

For most developers building cost-sensitive AI applications, the recommendation is clear: structure your prompts for caching from day one. The architectural patterns (static prefix, variable suffix) are provider-agnostic, so you'll benefit regardless of which API you use today or switch to tomorrow.

Want to calculate exact costs for your project?

Frequently Asked Questions

What is prompt caching in AI APIs?

Prompt caching (also called prefill caching) is a technique where AI providers store the processed representation of repeated prompt content. When the same prefix appears in subsequent requests, the provider reuses the cached computation instead of reprocessing it, resulting in faster responses and lower costs.

How much can prompt caching save on my AI API bill?

Savings vary by provider: Anthropic Claude offers up to 90% off cached input tokens, DeepSeek V4 provides a 90% discount (1/10th price) on cache hits, OpenAI gives 50% off cached tokens automatically, and Google Gemini offers reduced per-token pricing for context caching. Actual savings depend on your cache hit rate.

Do I need to change my code to use prompt caching?

It depends on the provider. OpenAI applies caching automatically with no code changes. Anthropic Claude requires you to mark cacheable content with cache_control breakpoints. DeepSeek applies caching automatically for repeated prefixes. Google Gemini requires explicit context caching API calls.

What is a cache hit rate and how do I improve it?

Cache hit rate is the percentage of requests that successfully match cached content. To improve it, keep your system prompts and static context at the beginning of your messages, batch requests with the same prefix together, avoid randomizing prompt structures, and ensure cached content meets the provider's minimum token threshold.

Does prompt caching affect response quality?

No. Prompt caching only affects how the input is processed — it stores the computed key-value attention states from your prompt. The model generates the same output regardless of whether the input was cached or freshly computed. It is purely a cost and latency optimization.