Calculate exact bottom-line dollars saved with Anthropic, OpenAI, and DeepSeek prompt caching. Model cache hit rates, prefix sizes, and annual gross margin expansion.
| Provider & Model | Standard Input | Cache Write Rate | Cache Read Rate | Effective Discount | Minimum Cache Size | Cache TTL Window |
|---|---|---|---|---|---|---|
| Anthropic Claude 3.7 Sonnet | $3.00 / 1M | $3.75 / 1M | $0.30 / 1M | 90.0% Off | 1,024 tokens | 5 minutes (refreshed on hit) |
| OpenAI GPT-4o | $2.50 / 1M | $2.50 / 1M | $1.25 / 1M | 50.0% Off | 1,024 tokens | Automatic (typically 5-10 min) |
| Anthropic Claude 3.5 Haiku | $0.80 / 1M | $1.00 / 1M | $0.08 / 1M | 90.0% Off | 2,048 tokens | 5 minutes (refreshed on hit) |
| DeepSeek V3 | $0.14 / 1M | $0.14 / 1M | $0.014 / 1M | 90.0% Off | 1,024 tokens | Automatic persistent caching |
| DeepSeek R1 Reasoning | $0.55 / 1M | $0.55 / 1M | $0.14 / 1M | 74.5% Off | 1,024 tokens | Automatic persistent caching |
To maximize prompt caching ROI, you must structure your prompt payloads with strict determinism. AI providers match prefixes sequentially from the very first token. If a single dynamic character (such as an unpredictable timestamp or user ID) is placed near the top of the prompt, the entire remaining context cache is invalidated.
By placing all static tokens at the beginning of the message array and placing dynamic user inputs strictly at the end, your application guarantees that the first 5,000 to 50,000 tokens achieve an unbroken cache hit on every single invocation.
To understand why prompt caching yields up to 90% cost reductions, one must examine the computational mechanics of self-attention. In transformer inference, prefill (processing the input prompt) scales quadratically with sequence length $O(N^2)$. Computing Key-Value (KV) vector projections across 100,000 tokens consumes massive floating-point operations (FLOPs) and fills high-bandwidth memory (HBM).
When prompt caching is engaged, the inference engine freezes the KV tensor states of static prefix tokens (such as system guidelines, API schemas, or reference codebases) in cluster VRAM or ultra-fast NVMe storage. On subsequent requests, the model skips the entire prefill attention step for those tokens, converting a compute-intensive matrix multiplication into a simple memory lookup.
Anthropic Claude charges $0.30/M on cache hits ($3.00/M standard), yielding a 90% discount with a 5-minute TTL. DeepSeek-V3 automatically caches prefixes in 64-token increments, cutting costs from $0.27/M down to $0.07/M (a 74% discount). OpenAI provides a 50% discount ($1.25/M on GPT-4o). For production agentic applications, caching transforms unprofitable features into high-margin SaaS workflows.
Python script showing exact implementation of Anthropic ephemeral cache breakpoints across multi-turn chats.
import anthropic
client = anthropic.Anthropic()
def query_cached_knowledge_base(system_manual: str, user_question: str):
"""Cache a massive 50k-token manual and query with 90% token discounts."""
response = client.messages.create(
model="claude-3-7-sonnet-20250219",
max_tokens=1024,
system=[
{
"type": "text",
"text": system_manual, # 50,000 tokens of company SOPs
"cache_control": {"type": "ephemeral"} # Cache breakpoint
}
],
messages=[{"role": "user", "content": user_question}]
)
# Check cache telemetry in usage metadata
usage = response.usage
print(f"Cache Creation: {getattr(usage, 'cache_creation_input_tokens', 0)} tokens")
print(f"Cache Read (90% off): {getattr(usage, 'cache_read_input_tokens', 0)} tokens")
return response.content[0].text
Watch out for these operational traps when engineering prompt caching layers.
Inserting dynamic dates or session IDs at the top of your system prompt shifts all subsequent tokens, causing a 0% cache hit rate and a 25% write penalty on every request.
Anthropic caches evict after 5 minutes of silence. If user queries arrive every 7 minutes, you pay cache creation write fees ($3.75/M) repeatedly without ever getting read discounts.
Prompt caching requires minimum prefix sizes: 1,024 tokens on OpenAI and 2,048 tokens on Claude Haiku/Sonnet. Prompts smaller than this threshold receive zero discount.
Routing requests across multiple geographic endpoints (us-east and us-west) splits your cache affinity, cutting effective hit rates in half.
Explore complementary financial modeling tools across our benchmark index.
Calculate token waste from unpruned multi-turn conversation histories.
Analyze monthly seat economics using Claude 3.7 and DeepSeek keys.
Compare 90% Claude caching against 50% OpenAI caching.
Rankings of the lowest cost models per million tokens.