Sections (9)▾
- 01How does Gemini prompt caching work?
- 02Which models can use each mode?
- 03What does Gemini context caching cost?
- 04How often does Gemini hit the cache?
- 05What does the hit rate do to the bill?
- 06How can you raise a Gemini cache hit rate?
- 07Read cached tokens or create a cache
- 08When should you use an explicit cache?
- 09Track cache savings with Requesty
Gemini prompt caching is automatic on Gemini 2.5 and newer. On the Gemini Developer API, Gemini 4 uses implicit caching and cached input costs 95% less than standard input in December 2026; Gemini 3 and 2.5 also support explicit caches with hourly storage charges. The discount applies on a cache hit, but Google does not guarantee one. Google's caching documentation covers both modes.
How does Gemini prompt caching work?
Context caching stores prompt content so that later requests can reuse it. When a request uses cached content, those input tokens are billed at the cached rate. A prefix is the beginning of a prompt: a system instruction or shared document can remain there unchanged across requests.
Google has two modes on the Gemini Developer API:
| Mode | Setup | Storage fee | Retention | Model support |
|---|---|---|---|---|
| Implicit | Automatic | None | No guaranteed hit | Gemini 2.5 and newer |
| Explicit | Create a cache with a TTL | Prorated hourly charge | Retained for the configured TTL | Gemini 3 and 2.5 |
TTL is the length of time a cache is kept. An explicit cache defaults to one hour when you do not set a TTL. According to Google's GenerateContent documentation, a request that uses an explicit cache does not also use implicit caching.
The API determines which mode is available. Google's Interactions API supports implicit caching only. Creating an explicit cache on a supported Gemini 3 or 2.5 model requires GenerateContent.
Which models can use each mode?
The Gemini Developer API breaks down as follows:
| Model family | Implicit caching | Explicit caching |
|---|---|---|
| Gemini 4 Hydrogen, Neon, Carbon and Argon | Yes | No |
| Gemini 3, including 3.8 Flash and 3.1 Pro | Yes | Yes |
| Gemini 2.5 | Yes | Yes |
On the Gemini Developer API, implicit caching requires at least 4,096 tokens for Gemini 4 and the Gemini 3 models listed in Google's caching documentation, and at least 2,048 tokens for Gemini 2.5. Google's Gemini 4 Argon migration guide recommends placing static content first to help automatic caching.
From January 12, 2027, Google Cloud adds TTL configuration for cache control on Gemini 4 Hydrogen and later models. The default cache write price will be 1.25 times the standard input price, with longer retention costing more. See the Agent Platform documentation for that pricing.
What does Gemini context caching cost?
These are December 2026 Standard tier input prices per million tokens. Implicit caching has no separate storage fee.
| Model | Standard input | Cached input | Cached input discount |
|---|---|---|---|
| Gemini 4 Hydrogen | $1.50 | $0.075 | 95% |
| Gemini 4 Neon | $3.00 | $0.15 | 95% |
| Gemini 4 Carbon and Argon | $4.00 | $0.20 | 95% |
| Gemini 3.8 Flash | $0.75 | $0.075 | 90% |
Source: Google's Gemini API pricing page. The same rates apply to these models in Requesty's model catalog.
Carbon and Argon moved to these prices on December 1, 2026. Their introductory rate was $2.00 per million standard input tokens and $0.10 per million cached input tokens. Gemini 4 Argon is deprecated: from December 15, 2026, Google routes Argon requests to Gemini 4 Carbon.
For an explicit Gemini 3.8 Flash cache, storage costs $0.50 per million tokens per hour through December 31, 2026. On January 1, 2027, standard input rises to $1.50, cached input to $0.15 and storage to $1.00 per million tokens per hour. Our Gemini API pricing guide has more on the rate card.
How often does Gemini hit the cache?
Vertex (Gemini) had the lowest cache hit rate among 15 major providers in Requesty's November 2026 provider data. The hit rate is cached input tokens divided by total input tokens. Its 45.21% figure covers Vertex (Gemini) traffic, not traffic on the Gemini Developer API.
| Provider | Cache hit rate |
|---|---|
| Vertex (Claude) | 87.60% |
| Bedrock | 87.15% |
| Anthropic | 80.41% |
| OpenAI | 76.06% |
| Vertex (Gemini) | 45.21% |
One caveat: these providers handle different workloads, and providers can report cached tokens differently. A long agent session with a stable prefix can cache much more of its input than a one-off request.
The model-level numbers add useful context. In Requesty's production rankings for September 28 to November 30, 2026, Gemini 4 Neon had an 84.6% cache hit rate and Gemini 4 Argon had 70.2%. In a separate coding benchmark using the same agent across 129 tasks, Gemini 4 Hydrogen reached 95.3%.
Those figures measure different samples. The provider average is a starting point for a cost estimate; your own prompt pattern determines the result to watch.
For the write and read charges on other providers, see our guides to Anthropic prompt caching and cache read prices across providers.
What does the hit rate do to the bill?
Take 1,000 requests with 40,000 input tokens each: 40 million input tokens in total. The bill below covers input only, at December 2026 prices.
Google's Interactions API caching documentation says Gemini 4 recomputes a trailing window of 2,050 tokens at the standard input rate. The full previous request is cached only when the new turn adds at least 2,050 tokens. For a 40,000-token request, that leaves at most about 94.9% of input tokens available at the cached rate.
The calculation for each scenario is:
cost per million = standard input price x (1 - hit rate) + cached input price x hit rate
| Scenario | Hit rate | Input bill for 40 million tokens |
|---|---|---|
| Gemini 4 Hydrogen, no caching | 0% | $60.00 |
| Hydrogen at the Vertex (Gemini) provider rate | 45.21% | $34.23 |
The 45.21% rate is the Vertex (Gemini) average across models and workloads, so your own rate will differ. At that rate, caching takes $25.77 off the input bill.
At December 2026 Gemini 3.8 Flash rates, creating a cache for a 25,000-token prefix costs $0.01875, storing it for one hour costs $0.0125, and a cached read costs $0.001875. Google's Agent Platform caching overview describes the cache-creation charge.
One cached read plus creation and storage costs $0.033125, compared with $0.01875 for one uncached read, so one read does not pay off. Two cached reads cost $0.035 with creation and storage, compared with $0.0375 uncached. The break-even point is two reads within the hour.
How can you raise a Gemini cache hit rate?
Start with the content your requests share. Google's Gemini 4 Argon migration guide recommends placing static content first and using at least 4,096 tokens for automatic caching on the Developer API.
Check your Gemini prompt
0 of 5 done
A Google staff reply recommends a warm-up request followed by closely spaced requests. Google also says that changing thinking_level invalidates the whole Gemini 4 cache. Adding, removing or reordering tools invalidates the system instruction and conversation history cache.
To inspect cached token counts, Google's documentation shows usage_metadata.cached_content_token_count in GenerateContent responses and usage.total_cached_tokens in Interactions API responses. In long conversations, account for the trailing window described in the cost example above.
Read cached tokens or create a cache
These examples follow Google's GenerateContent caching documentation and Requesty's auto caching documentation. The repeated text stands in for a shared document; use your own stable content to test a workload.
The implicit examples send the same prefix twice and print the cached token count for each response. A second request can still miss the cache.
Install google-genai and set GOOGLE_API_KEY.
import os
from google import genai
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
prefix = "The project uses Python for data processing. " * 5000
for question in ["What language does the project use?", "What is it used for?"]:
response = client.models.generate_content(
model="gemini-4-hydrogen",
contents=prefix + "\n" + question,
)
print(response.usage_metadata.cached_content_token_count)Install google-genai and set GOOGLE_API_KEY. The cache is retained for one hour and incurs storage charges. The client pins the v1beta API version: with google-genai 3.7.0, caches.create on the default v1 endpoint returned a 404 in our test.
import os
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["GOOGLE_API_KEY"],
http_options=types.HttpOptions(api_version="v1beta"),
)
document = "The project uses Python for data processing. " * 5000
cache = client.caches.create(
model="gemini-3.8-flash",
config=types.CreateCachedContentConfig(
contents=[document],
ttl="3600s",
),
)
response = client.models.generate_content(
model="gemini-3.8-flash",
contents="What language does the project use?",
config=types.GenerateContentConfig(cached_content=cache.name),
)
print(response.usage_metadata.cached_content_token_count)
client.caches.delete(name=cache.name)The last line deletes the cache so storage charges stop. To keep reusing it instead, drop that line and extend its TTL with client.caches.update(name=cache.name, config=types.UpdateCachedContentConfig(ttl=...)). Both methods are covered in Google's caching documentation.
Install openai and set REQUESTY_API_KEY. Gemini implicit caching needs no auto_cache flag.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://router.requesty.ai/v1",
api_key=os.environ["REQUESTY_API_KEY"],
)
prefix = "The project uses Python for data processing. " * 5000
for question in ["What language does the project use?", "What is it used for?"]:
response = client.chat.completions.create(
model="google/gemini-4-hydrogen",
messages=[{"role": "user", "content": prefix + "\n" + question}],
)
details = response.usage.prompt_tokens_details
print(details.cached_tokens if details else 0)When should you use an explicit cache?
On the Gemini Developer API, use implicit caching for Gemini 4 and structure repeated requests around a stable prefix. On Gemini 3 or 2.5, an explicit cache gives you TTL control and retention for the configured period, with a storage charge to include in the calculation.
For a shared document or codebase on Gemini 3.8 Flash, compare the savings from expected cached reads with the creation and storage charges for the time you keep it. Then measure the complete workload: a cheap cached-token price has less effect when only a small share of input tokens gets a cache hit.
Track cache savings with Requesty
Requesty's auto caching documentation says Gemini implicit caching needs no flag. Cache analytics show hits and savings even without setting auto_cache, so you can compare the result by model.
Requesty can route across providers and add cache breakpoints for providers that require them. It cannot guarantee a Google implicit cache hit or add explicit caching to Gemini 4 on the Gemini Developer API.
For Vertex Gemini, Requesty skips auto caching when the cacheable prefix contains file attachments with URIs outside Google Cloud Storage. Inline or base64 attachments and gs:// URIs are supported.
Start by grouping requests with the same static prefix, then check cached input tokens and cost in the dashboard. Compare those figures with the output you need from Claude or GPT before choosing a route.
FAQ
Does Gemini have prompt caching?+
Yes. Google calls it context caching. Gemini 2.5 and newer have automatic implicit caching, while Gemini 3 and 2.5 also support explicit caches through the GenerateContent API.
Is Gemini implicit caching on by default?+
Yes. Implicit caching is on by default for Gemini 2.5 and newer, with no setup calls or storage fees. A cache hit is not guaranteed.
Does Gemini 4 support explicit context caching?+
On the Gemini Developer API, Gemini 4 uses implicit caching only. Explicit caching is supported on Gemini 3 and 2.5 through the GenerateContent API.
How much does Gemini context caching cost?+
In December 2026, Gemini 4 Hydrogen cached input costs $0.075 per million tokens, compared with $1.50 for standard input. Explicit caches on Gemini 3.8 Flash also cost $0.50 per million stored tokens per hour through December 31, 2026.
What was the Gemini cache hit rate in November 2026?+
Vertex (Gemini) had a 45.21% cache hit rate in Requesty's November 2026 provider data. The rate measures cached input tokens divided by input tokens and varies with the workload.
How many tokens does Gemini implicit caching require?+
On the Gemini Developer API, Gemini 4 and the Gemini 3 models listed in Google's caching documentation require at least 4,096 tokens for implicit caching. Gemini 2.5 requires at least 2,048 tokens.
