Comparison

Prefix Caching Cost Savings Self-Hosted: OpenAI vs Anthropic vs Gemini Pricing

Back to BlogWritten by Published Dec 1, 2026
Prefix Caching Cost Savings Self-HostedPrompt Caching Pricing ComparisonAnthropic Cache PricingGemini Context CachingOpenAI Cached Input DiscountSelf-Hosted LLM CachingKV CacheSGLangLLM InferenceGPU Cloud
Prefix Caching Cost Savings Self-Hosted: OpenAI vs Anthropic vs Gemini Pricing

Prefix caching cost savings self-hosted isn't a bigger or smaller discount than what Anthropic, OpenAI, and Gemini publish for their hosted APIs. It's a structurally different bet. Anthropic charges a premium to write to its cache and expects you to earn that back on reuse. Gemini charges an hourly storage fee whether or not anyone ever reads what you cached. OpenAI's discount carries no write-side cost at all. Self-host with vLLM or SGLang and none of those mechanics apply, because there's no caching product to bill, only GPU time you either spend or don't. Here's what each provider actually publishes, and what the self-hosted alternative actually costs.

TL;DR: Prefix Caching Cost Savings Self-Hosted vs OpenAI, Anthropic, Gemini

  • Anthropic: reads run 0.1x base input (90% off), but a 5-minute write costs 1.25x and a 1-hour write 2x, per Anthropic's pricing as of 1 Dec 2026.
  • OpenAI: GPT-5.1 cached input is $0.125/M against $1.25/M standard, 90% off, no write fee, per OpenAI's pricing page.
  • Gemini: Gemini 3.1 Pro charges $0.20/M to read a cache (90% off $2.00/M) plus $4.50/M tokens per hour of storage, hit or not.
  • Self-hosted: vLLM and SGLang charge no write or storage fee; the saving is throughput on the instance you rent, like $2.86/hr on a Spheron H100 SXM5 as of 04 Dec 2026.
  • Bottom line: all three publish a ~90% read discount, yet bill differently, since write and storage mechanics differ.

The Cache Discount Each Provider Actually Publishes

Anthropic, OpenAI, and Gemini each publish a cache-read discount close to 90% on their flagship model, but the read discount is only half the pricing. Two of the three also charge something to create or hold the cache in the first place, and the third doesn't.

ProviderCache WriteCache ReadStorage While Cached
Anthropic, 5-minute TTL25% more than base input10% of base input (0.05x on Opus 5.5/Sonnet 5.5, 0.025x on Fable/Mythos 5.1 and 5.2)None
Anthropic, 1-hour TTL2x base inputSame read price as aboveNone
OpenAI, GPT-5.1No separate write charge, activates automatically above 1,024 tokens$0.125/M vs $1.25/M standard input (90% off)None
Gemini 3.1 ProNo separate write line item on the pricing table$0.20/M vs $2.00/M standard input (90% off, prompts up to 200K tokens)$4.50 per million tokens, per hour

Anthropic's own explanation of the 5-minute tier is direct: "Writing to the cache costs 25% more than our base input token price for any given model," while "using cached content is significantly cheaper, costing only 10% of the base input token price," according to Anthropic's prompt caching announcement. The 1-hour option costs more to create: Anthropic's own docs state "cache write tokens with a 1-hour TTL are 2 times the base input tokens price." Both TTLs read at the same discounted rate, with exceptions carved out by model: "cache hits and refreshes on Claude Opus 5.5 and Claude Sonnet 5.5 are priced at 0.05x the base input price," and "cache hits and refreshes on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, and Claude Mythos 5.1 are priced at 0.025x the base input price," per Anthropic's pricing documentation. The full per-model Anthropic rate card beyond caching alone is in our Claude Opus 5 API pricing vs self-hosted breakdown.

OpenAI's mechanism looks different from the start. Prompt caching activates automatically once a prompt exceeds 1,024 tokens, with no API flag to set and no separate charge to create the cache entry. What you pay is a flat, discounted rate on every token that hits it. OpenAI's own pricing table lists GPT-5.1 at $1.25 per million tokens for standard input and $0.125 for cached input, a 90% discount on the tokens that hit the cache. For the broader OpenAI rate card beyond caching alone, see GPT-5.6 Sol pricing vs self-hosted LLMs.

Gemini's published numbers land at the same 90% read discount as Anthropic and OpenAI, but the structure is a third shape entirely. Google's pricing page lists Gemini 3.1 Pro at $2.00 per million tokens standard input for prompts up to 200,000 tokens, $0.20 per million tokens to read a cached prefix at that same tier, and $4.50 per million tokens for every hour the cache is held in storage. There's no separate line item on the table for creating the cache, only the per-hour storage charge and the discounted read rate. Our Gemini 3 Pro API pricing vs self-hosted LLMs guide covers the full standard and long-context tiers this caching rate sits under.

Pricing fluctuates based on provider and GPU availability. Third-party rates above (Anthropic, OpenAI, Gemini) reflect their published pricing pages as of 1 December 2026 and may have changed since. Spheron rates are live as of 04 Dec 2026. Check current GPU pricing → for live rates.

Why a 90% Discount on One Provider Isn't the Same Trade as a 50% Discount Elsewhere

A headline discount percentage tells you nothing about whether caching actually saves money on your traffic pattern, because the premium or fee attached to getting that discount can erase it entirely at low reuse counts.

Anthropic's Write Premium Means the First Use Costs More, Not Less

Treat a 5-minute cache write and its reads as one transaction, and the arithmetic is straightforward: a write costs 1.25x base input, and every subsequent read on that same prefix costs 0.1x. Compare that against sending the same prefix fresh, at 1.0x, every single time. For N total requests on the same prefix, caching costs 1.25 + 0.1(N-1) against an uncached N x 1.0. Work through the numbers and caching only turns cheaper once N reaches 2, meaning a single cache read after the initial write is already enough to come out ahead. The 1-hour tier changes that threshold because its write costs more: at 2 + 0.1(N-1) against N x 1.0, caching doesn't beat sending the prefix fresh until N reaches 3, or two cache reads after the write. Neither of these breakeven points appears as a stated number on Anthropic's pricing page; they fall directly out of the published write and read multipliers. Miss that premium and a workload that writes a cache once per session but rarely reuses it within the TTL window pays more than it would have paid for no caching at all.

Gemini's Storage Fee Runs Whether You Get a Hit or Not

Anthropic's downside is a one-time premium on the write. Gemini's downside is a running meter. Cache a 50,000-token system prompt for an hour and query it just once in that window: storage costs $4.50/M x 50,000 tokens = $0.225 for the hour, plus a single read at $0.20/M x 50,000 tokens = $0.01, for a total of roughly $0.235. Sending that same 50,000-token prompt once, uncached, at the standard $2.00/M rate costs $0.10. In this single-use case, caching costs more than twice what skipping it would have, because the storage fee accrues for the full hour regardless of how many times, or how few, the cache actually gets read. The context engineering and KV cache guide for production agents covers the broader economics of sizing a workload around cache hit rate rather than raw context length, which is exactly the variable that decides whether Gemini's storage fee pays for itself.

Even OpenAI's Own Discount Isn't One Fixed Number

OpenAI has no write premium and no storage fee, which makes it the simplest of the three to reason about, but the discount itself still isn't a constant across its own lineup. GPT-5.1 and GPT-5 both show a $1.25 standard input rate against a $0.125 cached rate on OpenAI's pricing table, a 90% reduction. Older models in the same family discount less: a model priced at $2.00 standard input with a $0.50 cached rate is a 75% discount, and one at $2.50 standard with $1.25 cached is only 50% off. Nothing about "OpenAI's cache discount" resolves to a single percentage without naming the model. The structural point holds across all three providers: a published discount is the starting number, not the answer, and the write premium, the storage meter, or the specific model row is what actually decides your bill.

Prefix Caching Cost Savings Self-Hosted: The Discount Is the Default, Not a Line Item

Running inference on rented GPUs skips this entire structure, because there's no separate caching product sitting on top of the bill to price in the first place. vLLM's Automatic Prefix Caching and SGLang's RadixAttention are both part of the inference engine itself: the server hashes or indexes KV cache blocks as requests come in, reuses them for anything that shares a matching prefix, and evicts the least-recently-used blocks once memory fills, with no flag to pay for turning it on and no meter running in the background while it sits idle.

vLLM's own design documentation describes the mechanism plainly: "we hash each kv-cache block by the tokens in the block and the tokens in the prefix before the block." A block has to be completely full, 16 tokens by default, before it becomes eligible for reuse, and when the cache runs out of room vLLM evicts the least-recently-used block rather than billing you to keep it resident. SGLang takes a different data structure to the same end: RadixAttention organizes cached KV tensors in a radix tree keyed by token sequence. Neither engine distinguishes a "write" from a "read" the way a billed API does; a block is computed once and reused for free every time after that, for as long as it stays resident.

That reuse doesn't lower your GPU bill directly, it raises the throughput the GPU-hour you're already paying for actually delivers, since prefill compute the engine gets to skip is capacity it can spend serving the next request instead. On one 8x B300 spot node we rented on Spheron (ES, UK South 1, vLLM 0.33.0, 8 Nov 2026), DeepSeek V4.1 Flash as two 4-GPU copies did 268.6 tok/s for one user and 6,851.2 tok/s for the node at 64 users, median first token 273 ms, $2.01 per million output tokens. None of that per-token cost carries a separate caching charge, because there isn't one to bill: the throughput number already reflects however much prefix reuse that traffic pattern produced. Our guide to building a self-hosted OpenAI-compatible API with vLLM walks through the actual server setup, including the flag that turns Automatic Prefix Caching on.

This path has real costs the API side doesn't. Self-hosting means running and tuning vLLM or SGLang yourself, block size, eviction behavior, and KV cache capacity included, with no managed layer handling that the way a hosted API does. Spot capacity adds its own risk: every 8-GPU spot type we used was reclaimed at least once on 14 Oct 2026, and on 16 Oct one B200 region stopped five of our spot VMs in a day, which matters directly here because a prefix cache lives in that VM's memory and disappears the moment the VM does. If you serve inference on spot, keep two copies of every model on different nodes, spread across regions or providers, and set up automatic recovery. And the fixed cost of a rented GPU only beats API-side cache discounts at real volume; a handful of cache-eligible requests a day doesn't justify renting and babysitting an instance, uncached API calls or a cheap managed tier are the better fit until volume actually clears that threshold. Spheron's own on-demand and spot rates are published live rather than quoted on request, which at least makes that threshold a number you can check against your own traffic instead of a sales estimate.

Caching only saves money as a line item if you're being billed for one in the first place. Self-host with vLLM or SGLang and the discount is just how much more throughput your GPU-hour gets you.

Get started on Spheron →

FAQ / 04

Frequently Asked Questions

No. OpenAI's prompt caching activates automatically on prompts over 1,024 tokens with no separate write charge, so you're only billed differently on the tokens that hit the cache. On GPT-5.1, cached input runs $0.125 per million tokens against $1.25 per million for standard input, a 90% discount with no write-side cost at all, per OpenAI's own pricing page.

Because Anthropic charges a premium to write to the cache before any discount applies: 1.25x the base input price for a 5-minute cache, 2x for a 1-hour cache. A single write with no reuse costs more than sending those tokens uncached. The math only turns in your favor once you reuse that prefix, roughly one cache read for a 5-minute cache or two for a 1-hour cache, per Anthropic's published multipliers.

Yes. Gemini 3.1 Pro bills $4.50 per million tokens for every hour a context cache sits in storage, independent of whether that cache gets a single read or a thousand. A cached prefix you only query once in that hour still costs the full hour of storage plus the discounted read, which can land above what sending the prompt once, uncached, would have cost.

No, because there's nothing to bill. vLLM's Automatic Prefix Caching and SGLang's RadixAttention are server mechanisms built into the inference engine itself, not a metered API feature. Reusing a KV cache block just means the GPU spends less time on prefill and more time serving the next request, inside the GPU-hour you're already paying for, for example $2.86/hr on a Spheron H100 SXM5 as of 04 Dec 2026.

// Try It Yourself

Try It on Real GPUs

The GPUs behind these guides are the ones you can rent here: H100s, H200s, B200s, and more, billed per minute after a 20-minute minimum runtime, with no contracts. Pick one and you are live in under two minutes.

View Pricing
→
Or talk to our team
Spheron GPU instance going live and linking data centers across the globe