Prompt Caching Compared: Claude vs GPT vs Gemini Pricing & Savings (2026)
Claude, GPT and Gemini all cache repeated prompt context to cut input-token costs, but the mechanics and savings differ a lot: Claude's explicit prompt caching gives roughly 90% off cached input tokens, GPT's automatic caching gives around 50-75% off with zero setup, and Gemini's context caching adds a small storage fee on top of a discounted token rate. Picking the right one — or routing to whichever is cheapest per task — can cut a chatty app's token bill by more than half.
How each provider's caching actually works
Claude (Anthropic): You explicitly mark a block of the prompt (system instructions, a long document, a tool schema) with a cache breakpoint. The first call is a "cache write" and costs about 1.25x the normal input price. Every subsequent call within the cache TTL (5 minutes by default, extendable to 1 hour) that reuses the same prefix pays only around 0.1x the normal input price for the cached portion. It's the deepest discount of the three, but it requires you to structure prompts so the static part comes first and the variable part comes last.
GPT (OpenAI): Caching is automatic for prompts over roughly 1,024 tokens — no API changes needed. The system detects a repeated prefix and applies a discount, typically in the 50-75% range depending on model and prompt length. It's less aggressive than Claude's cache-read discount, but there's nothing to configure, which makes it forgiving for teams that don't want to redesign their prompt structure.
Gemini (Google): Context caching works more like a stored resource — you upload a chunk of context (a codebase, a long system prompt, reference documents) and get a cache handle back. Cached tokens are billed at a reduced input rate, but you also pay a small per-hour storage fee for as long as the cache is kept alive. This model is best suited to large, mostly-static context (think: a 50k-token knowledge base reused across thousands of requests) rather than short conversational system prompts.
Side-by-side cost mechanics
| Provider | Setup | Cache write cost | Cache read discount | TTL |
|---|---|---|---|---|
| Claude | Manual cache breakpoints | ~1.25x input price | ~90% off | 5 min (or 1 hr option) |
| GPT | Automatic (>1k tokens) | Normal price | ~50-75% off | Minutes, provider-managed |
| Gemini | Explicit cache upload | Normal price + storage fee | Reduced input rate | Configurable, hourly billing |
A real-world example
Say you run a support assistant with a 6,000-token system prompt (product docs, tone guidelines, tool definitions) and it handles 2,000 requests a day. Without caching, that system prompt alone is re-billed on every single call — 12 million input tokens a day just for boilerplate.
With Claude prompt caching, after the first write you pay roughly 90% less on that 6,000-token block for every subsequent call in the TTL window — the daily boilerplate cost effectively collapses to the size of one or two writes plus cheap reads. With GPT's automatic caching you'd see a smaller but still meaningful cut, no code changes required. With Gemini, if the same 6k-token context is reused across many requests within an hour, the storage fee is trivial compared to the token savings; if your traffic is bursty with long idle gaps, the storage fee can eat into the benefit.
The practical takeaway: caching helps most when (1) a large chunk of your prompt is static and (2) requests are frequent enough that the cache stays warm. Low-traffic or highly dynamic prompts see much smaller gains from any provider's caching.
Combining caching with a cheaper relay
Caching reduces the token count you're billed for — but the per-token price you start from still matters, and that's the part caching alone doesn't fix. Official API pricing also assumes a US-billed account with a credit card, which isn't always practical for developers outside the US.
This is where a relay like Safa API (aisafa.xyz) is a useful complement rather than an alternative to caching: it sits in front of Claude, GPT and Gemini through one OpenAI-compatible endpoint, at lower per-token prices than official rates, and it passes through prompt caching correctly so you keep the discount described above. Signup doesn't require a credit card — Alipay works — which matters for teams that don't have a US-issued card to put on file. Point any client that already speaks the OpenAI SDK format — Claude Code, Cline, SillyTavern, custom scripts — at one base URL and switch between Claude, GPT and Gemini models without juggling three separate accounts, three billing pages, and three sets of API keys.
Frequently Asked Questions
Does prompt caching work the same way through a relay as through the official API?
Yes, as long as the relay forwards your cache breakpoints (Claude) or preserves prompt structure (GPT/Gemini) unchanged. Safa API passes requests through to the underlying provider without rewriting your prompt, so cache hits behave the same as calling the provider directly — you just pay a lower base rate on top.
Which provider's caching saves the most money?
For a static system prompt reused across many short-lived requests, Claude's ~90% cache-read discount is the deepest. For teams that want zero configuration, GPT's automatic caching is the easiest to benefit from immediately. For large, mostly-static context reused over longer periods, Gemini's context caching can be the most cost-effective despite the storage fee.
Is prompt caching worth it for low-traffic apps?
Not always. If your cache TTL expires between requests (e.g., one user message every 20 minutes), you keep paying the more expensive "write" price and rarely hit the cheap "read" price. In that case, focus on lowering your base per-token rate instead — for example by routing through a cheaper relay — rather than restructuring prompts around caching.
官方直连 · 一个接口接入 Claude / GPT / Gemini · 7×24 稳定
免费注册试用 →