Quick answer: Prompt caching stores the processed version of your AI agent's system prompt so the LLM skips recomputation on repeated requests. Anthropic charges 90% less for cached tokens, OpenAI gives 50–75% off, and Google offers 90% savings. For agents making 100+ daily requests with stable system prompts, caching alone cuts API costs by 70–90%.
Every AI agent sends the same system prompt — role instructions, tool definitions, safety constraints, few-shot examples — with every single request. For a typical production agent, that's 2,000–10,000 tokens of identical content reprocessed thousands of times per day. Without prompt caching for AI agents, you're paying full price every time the LLM reads instructions it already knows by heart.
The fix is straightforward: prompt caching tells the provider to store the computed representation of your prompt prefix. Subsequent requests that share the same prefix hit the cache and cost a fraction of the original price. Research published in January 2026 ("Don't Break the Cache," arXiv) found that prompt caching delivers 41–80% cost reduction and 13–31% faster time-to-first-token across production agent workloads.
If you haven't read our breakdown of how much AI agents cost to run, start there for the full pricing picture. This guide focuses specifically on prompt caching — the single highest-leverage optimization in our cost optimization playbook.
If your agent's system prompt is over 1,024 tokens (most are), prompt caching is free money. It takes 10 minutes to implement and pays for itself on the second request.
How Prompt Caching Works
Prompt caching exploits a simple insight: LLMs process input tokens sequentially, and the computational state at any point in the sequence is deterministic. If you send the same prefix of tokens repeatedly, the provider can store the intermediate computation (the KV cache) and skip straight to processing the new, unique portion.
Here's the flow:
- First request — the full prompt is processed and the prefix computation is stored (cache write). You pay a small write premium.
- Subsequent requests — if the prompt starts with the same prefix, the cached computation is reused (cache read). You pay 50–90% less for the cached portion.
- Cache expiry — after a period of inactivity, the cache evicts. The next request triggers a fresh cache write.
The critical requirement is exact prefix matching. Even a single whitespace change invalidates the cache. This is why prompt architecture matters — and why most teams leave savings on the table.
Provider Comparison: Pricing and Mechanics
Each provider implements prompt caching differently. Understanding the mechanics is essential for maximizing savings.
Anthropic (Claude)
Anthropic gives you the most control. You set explicit cache breakpoints using the cache_control parameter on content blocks:
{
"system": [
{
"type": "text",
"text": "You are an AI code review agent for a Node.js project...",
"cache_control": { "type": "ephemeral" }
}
]
}
Key details:
| Feature | Value |
|---|---|
| Cache read discount | 90% off base input price |
| Cache write premium | 25% above base (5-min TTL) or 100% above (1-hour TTL) |
| Default TTL | 5 minutes (refreshes on each hit) |
| Extended TTL | 1 hour (use "ttl": "1h" in cache_control) |
| Max breakpoints | 4 per request |
| Minimum tokens | 1,024–4,096 depending on model |
For a 1-hour TTL, set "cache_control": {"type": "ephemeral", "ttl": "1h"}. The write cost doubles, but it pays for itself after roughly 4 requests per hour against the same prefix.
Pricing per million tokens (Claude Sonnet 4.6):
| Token Type | Price |
|---|---|
| Base input | $3.00 |
| Cache write (5-min) | $3.75 |
| Cache write (1-hour) | $6.00 |
| Cache read | $0.30 |
That's a 10x reduction on cached tokens.
OpenAI
OpenAI takes the opposite approach: fully automatic caching with zero code changes.
Any prompt over 1,024 tokens is automatically cached. The cache starts at the first 1,024 tokens and extends in 128-token increments. No API flags, no breakpoints — it just works.
| Feature | Value |
|---|---|
| Cache discount (GPT-4o) | 50% off input tokens |
| Cache discount (GPT-4.1) | 75% off input tokens |
| Cache discount (GPT-5) | 90% off input tokens |
| Minimum tokens | 1,024 |
| TTL | 5–10 min of inactivity, clears within 1 hour |
| Setup required | None |
The trade-off: you get no control over what gets cached or for how long. But for most agent workloads, the defaults work well. Check for cached_tokens in the response usage object to verify cache hits.
Google Gemini
Google offers a hybrid approach with two mechanisms:
Implicit caching (automatic since May 2025): Works like OpenAI's automatic caching. Requires 1,024+ tokens. No guaranteed savings — Google applies the discount opportunistically.
Explicit caching: You create a CachedContent resource via the API, then reference it in requests. Guaranteed savings but involves storage fees:
| Feature | Value |
|---|---|
| Cache read discount | 90% off base input price |
| Storage cost | $1.00–$4.50 per million tokens per hour |
| Minimum tokens | 32,768 (explicit) |
| Default TTL | 1 hour (configurable, no min/max) |
Explicit caching makes sense for large reference documents (50K+ tokens) that many requests share — like a codebase summary or product documentation that your agent references throughout a session.
At the per-token level, Anthropic and Google offer the deepest discounts (90% off). OpenAI's GPT-4.1 and GPT-5 models match this with 75–90% off. The real savings depend on your hit rate — which is determined by how well you structure your prompts.
How to Structure Prompts for Maximum Cache Hits
The number one reason teams miss cache hits: dynamic content in the wrong place. Cache matching works on prefixes — if anything changes before the cache boundary, everything after it is recomputed at full price.
The Golden Rule: Static First, Dynamic Last
Structure every agent prompt in this order:
- System instructions (static) — role, personality, constraints
- Tool definitions (static) — function schemas, parameter descriptions
- Reference documents (semi-static) — codebase context, product docs
- Few-shot examples (static) — demonstration input/output pairs
- Conversation history (dynamic) — prior turns in the session
- Current user message (dynamic) — the actual request
Everything above the first dynamic element can be cached. Everything after it is reprocessed every time.
Five Patterns That Kill Cache Hits
-
Timestamps in system prompts.
"The current date is March 14, 2026"in your system prompt invalidates the cache every second. Move it to the first user message. -
Randomized tool ordering. If your agent framework generates tool schemas dynamically, ensure they're sorted deterministically. A different JSON key order = cache miss.
-
RAG context in system prompts. Retrieved documents change on every query. Put them after the cache boundary, in the user message — not the system prompt. See our prompt engineering guide for the context injection pattern.
-
Session-specific variables in the preamble. User IDs, session tokens, and feature flags belong in the dynamic section, not the static prefix.
-
Minor formatting changes. Trailing whitespace, newline differences, or JSON pretty-printing vs. minification — any character-level change breaks the cache. Standardize your prompt formatting.
The "Don't Break the Cache" research paper found that caching strategies that include dynamic tool results can actually increase latency compared to selective caching. Cache your static prefix aggressively, but exclude dynamic tool call results from cache blocks.
Real-World Cost Savings
Let's put concrete numbers on three common scenarios.
Scenario 1: Customer Support Agent
A support agent with a 5,000-token system prompt handling 1,000 conversations per day:
| Without Caching | With Caching | |
|---|---|---|
| Daily system prompt tokens | 5,000,000 | 5,000,000 |
| Cost (Claude Sonnet 4.6 at $3/M) | $15.00/day | — |
| Cache write (first request) | — | $0.02 |
| Cache reads (999 requests at $0.30/M) | — | $1.50/day |
| Daily savings | — | $13.48 (90%) |
| Monthly savings | — | $404 |
Scenario 2: Code Review Agent
A code review agent with a 10,000-token system prompt (including repo context and style guidelines) reviewing 200 PRs per day:
| Without Caching | With Caching | |
|---|---|---|
| Daily system prompt tokens | 2,000,000 | 2,000,000 |
| Cost (GPT-4.1 at $2/M) | $4.00/day | — |
| Cached reads (GPT-4.1 at $0.50/M) | — | $1.00/day |
| Daily savings | — | $3.00 (75%) |
| Monthly savings | — | $90 |
Scenario 3: Document Q&A Agent
An agent with a 50,000-token reference document cached as context, answering 500 queries per day:
| Without Caching | With Caching | |
|---|---|---|
| Daily document tokens | 25,000,000 | 25,000,000 |
| Cost (Claude Sonnet 4.6 at $3/M) | $75.00/day | — |
| Cache write (once) | — | $0.19 |
| Cache reads ($0.30/M) | — | $7.50/day |
| Daily savings | — | $67.31 (90%) |
| Monthly savings | — | $2,019 |
The pattern is clear: the bigger your static prefix and the more requests you make, the more caching saves. For high-volume agents, prompt caching alone can be the difference between a sustainable AI deployment and one that bleeds money.
Implementation Checklist
Here's how to enable prompt caching for your AI agent, start to finish:
-
Audit your system prompt. Identify what's static (instructions, tools, examples) vs. dynamic (timestamps, user context, RAG results). Separate them.
-
Reorder your prompt. Move all static content to the front. Dynamic content goes last, after the cache boundary.
-
Enable caching on your provider:
- Anthropic: Add
"cache_control": {"type": "ephemeral"}to your system message content blocks. Use up to 4 breakpoints for sections that change at different frequencies. - OpenAI: Nothing to do — automatic for prompts over 1,024 tokens. Just verify cache hits in the response.
- Google: For implicit caching, nothing to do. For explicit caching, create a
CachedContentresource via the API.
- Anthropic: Add
-
Verify cache hits. Check the response
usageobject:- Anthropic:
cache_read_input_tokens> 0 - OpenAI:
cached_tokens> 0 - Google:
cached_content_token_count> 0
- Anthropic:
-
Monitor your cache hit rate. Track
cache_read_tokens / total_input_tokensover time. A healthy rate is 80%+. If it's below 50%, you have dynamic content leaking into your static prefix. -
Standardize prompt formatting. Lock down whitespace, JSON key ordering, and tool schema generation. Any drift breaks the cache.
If your team shares AI agents through cowork.ink, centralized prompt management means every team member's requests hit the same cache. Shared prompts = higher cache hit rates = lower costs for everyone.
Advanced Techniques
Multi-Tier Caching with Anthropic
Anthropic allows up to 4 cache breakpoints. Use them to cache sections that change at different frequencies:
- Breakpoint 1 (1-hour TTL): System instructions + tool definitions (changes weekly)
- Breakpoint 2 (5-min TTL): Reference documents (changes per session)
- Breakpoint 3 (5-min TTL): Recent conversation history (changes per turn)
This way, your stable system prompt stays cached for an hour even if the conversation context cycles every few minutes.
Combining Prompt Caching with Semantic Caching
Prompt caching reduces the cost of processing the prompt. Semantic caching skips the LLM call entirely for queries similar to ones already answered. Layer them:
- Check semantic cache first — if a similar query was recently answered, return the cached response (cost: $0)
- If no semantic match, send to the LLM with prompt caching enabled (cost: 70–90% less than full price)
Together, these two techniques can reduce effective API costs by 95%+ for high-repetition workloads.
Batch Sequential Requests
When sending multiple concurrent requests to the same agent, send the first request alone to create the cache, then fire the remaining requests. This ensures all subsequent requests get cache hits instead of all simultaneously paying the cache write premium.
Common Mistakes to Avoid
Caching too little. If your system prompt is 3,000 tokens but you only cache the first 1,024, you're leaving 2,000 tokens of savings on the table. Cache the entire static prefix.
Ignoring cache write costs. Anthropic charges 25–100% extra for cache writes. If you have very low request volume (< 5 requests per cache TTL window), the write premium might exceed the read savings. Do the math for your traffic pattern.
Not monitoring cache hit rates. A code change that adds a timestamp to the system prompt can silently drop your cache hit rate from 95% to 0%. Alerting on cache hit rate drops is as important as alerting on error rates.
Over-caching dynamic content. As the "Don't Break the Cache" research demonstrated, naively caching everything — including tool call results — can increase latency. Be selective about what gets cached.
Get Started
Prompt caching is the simplest, highest-impact optimization for AI agent costs. Ten minutes of implementation yields 70–90% savings on input tokens, compounding across every request your agent handles.
If you're running agents as a team — shared code review agents, planning agents, customer support agents — cowork.ink centralizes prompt management so every team member's requests share the same cache. Higher hit rates, lower costs, zero duplicate work.
If you're running a personal agent, GoGogot works with any OpenRouter-compatible provider that supports caching — configure once, save on every session.
Try cowork.ink free — see how shared prompt management maximizes your cache hit rate.