Prompt Caching Calculator
Calculate exact savings from Anthropic and OpenAI prompt caching. Adjust system prompt size, cache hit rate, and monthly request volume to see your cost delta.
Prompt Configuration
Usage Parameters
Monthly Cost Comparison
| Model | Without cache | With cache | Monthly savings | Savings % |
|---|---|---|---|---|
| Claude 3.5 Haiku Cache read = 10% of input. Cache write = 25% surcharge on cached tokens. | — | — | — | — |
| Claude 3.5 Sonnet Cache read = 10% of input. Min cache prefix: 2,048 tokens. | — | — | — | — |
| Claude 3 Opus Cache read = 10% of input. Largest savings on expensive model. | — | — | — | — |
| GPT-4o Cache read = 50% of input. Automatic, no explicit management needed. | — | — | — | — |
| GPT-4o Mini Cache read = 50% of input. Cheapest model, smaller absolute savings. | — | — | — | — |
Select Model to Visualize
Frequently Asked Questions
How does Anthropic prompt caching work?▼
Anthropic's Claude prompt caching stores a processed version of your prompt prefix in memory. If you send the same prefix (at least 1,024 tokens for Claude 3 Haiku, 2,048 for Sonnet/Opus) on subsequent requests, cached tokens are charged at 10% of the normal input rate instead of 100%. Cache entries persist for 5 minutes with a sliding window refresh.
Does OpenAI have prompt caching?▼
Yes. OpenAI automatically caches prompt prefixes for GPT-4o and GPT-4o-mini on prompts of 1,024+ tokens. Cached tokens are charged at 50% of the input rate (not as aggressive as Anthropic's 10%). Cache hits occur when the prefix matches a previous request exactly. No explicit cache management is needed.
What is a cache hit rate?▼
Cache hit rate is the percentage of your requests that successfully reuse a cached prompt. A 90% cache hit rate means 9 out of 10 requests use the cached version. Higher hit rates occur when you have a consistent large system prompt sent on every request. Hit rates drop when prompts vary significantly between requests.
How do I maximize cache hit rate?▼
Structure prompts with the large, stable content first (system instructions, documents, tools) followed by the dynamic content (user message). Cache is keyed on the exact prefix — even a single character change invalidates it. Pin your static system prompt and append dynamic user input at the end. Use cache_control: {type: 'ephemeral'} in Claude to explicitly mark cache breakpoints.
Is prompt caching always worth it?▼
Caching saves money on repeated large system prompts but adds a cache write cost (25% on Anthropic, 100% on OpenAI — cache writes are charged normally). The savings are largest when: (1) your system prompt is very large (1K+ tokens), (2) cache hit rate is high (>50%), and (3) you make many requests per session. Low-volume or highly variable prompts won't benefit much.
Related Products
on GumroadAI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →AI Developer Prompts Pack
55 battle-tested prompt templates for the workflows developers actually use: code review, debugging, architecture, documentation, and testing. Stop writing prompts from scratch.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
LLM Cost Calculator
Compare monthly API costs across GPT-4o, Claude Sonnet, Gemini Pro, and 12+ models. Enter daily requests and token counts for instant cost estimates.
Open free tool →
AI Prompt Cost Calculator
Calculate daily and monthly API costs for GPT-4o, Claude 3.5, Gemini 1.5, and more. Enter token counts, model, and request volume to get instant cost projections.
Open free tool →
AI Hallucination Detector
Scan LLM-generated text for hallucination risk signals: fabricated citations, overconfident claims, suspect statistics, and verification gaps. Risk score 0-100 with highlighted problem spans.
Open free tool →
More Free Tools
Related Articles
LLM Structured Output: JSON Mode, Function Calling, and Tool Use in 2026
Complete guide to LLM structured output in 2026: OpenAI JSON mode vs structured outputs, Anthropic tool use, the Instructor library, Pydantic AI, validation patterns, reliability techniques, and real-world examples.
Vercel AI SDK Complete Guide 2026: Streaming, Tool Calls & Multi-Provider
The complete guide to the Vercel AI SDK in 2026. Learn streaming text and objects, tool calling, multi-provider setup, Next.js integration, and production patterns for building LLM-powered apps.
LiteLLM vs OpenRouter vs AI Suite: LLM Gateway & Model Routing in 2026
A comprehensive comparison of LiteLLM, OpenRouter, and AI Suite for LLM gateway and model routing in 2026 — unified API, model fallback, cost routing, rate limiting, caching, and deployment options with Python code examples.
Model Context Protocol (MCP) Complete Guide 2026
The definitive guide to MCP (Model Context Protocol) by Anthropic. Learn what MCP is, how its architecture works, how to build MCP servers, real-world integrations, and how it compares to function calling and plugins.
LLM Observability Tools 2026: OpenTelemetry, Langfuse, Arize Phoenix Compared
Compare LLM observability tools for 2026: Langfuse, Arize Phoenix, Helicone, LangSmith, and OpenTelemetry for LLMs. Tracing, evals, cost tracking, and self-hosting options.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →