AI Coding Agents
Gemini Implicit vs Explicit Context Caching: When Storage Costs Are Worth It
Gemini implicit caching applies a discounted read rate automatically when repeated input hits the cache, with no separate storage charge. Explicit caching lets you name and retain a cache object on supported models, with an hourly storage charge. Choose it when the cost of measured implicit misses exceeds the cost of holding the object.
The two mechanisms at a glance
| Implicit caching | Explicit caching | |
|---|---|---|
| Activation | Automatic, on by default | You create a cache object through the API |
| Control over what is cached | None; Gemini picks prefixes | You declare the content and reference it by name |
| Lifetime | Up to 24 hours on Vertex, with most entries expiring sooner | TTL defaults to 60 minutes on Vertex, extendable with no maximum duration |
| Storage charge | None | Billed per 1M tokens per hour |
| Cache creation input on Vertex | Standard input price unless cache write pricing applies | Standard input price unless cache write pricing applies |
| Read discount (Vertex) | 95% on Gemini 4 and later, 90% on Gemini 3 and 2.5, 75% on Gemini 2 and earlier | 90% on Gemini 3 and 2.5, 75% on Gemini 2 and earlier |
| Minimum tokens | 2,048 to 6,144 depending on model and platform | 2,048 on the Gemini 2 family, 4,096 on the Gemini 3 family per Vertex |
| Model coverage | Enabled by default for Gemini 2.5 and newer on the Developer API, with a separate supported-model list on Vertex | Supported Gemini 3 and 2.5 models via Developer API generateContent or Vertex as of November 30, 2026 |
Implicit caching: free to hold, best-effort by design
Implicit caching is enabled by default on the Gemini API for all Gemini 2.5 and newer models, in both stateful and stateless conversation modes, and Google states that all Google Cloud projects have it enabled on Vertex. You configure nothing; when a request hits, the savings are passed on automatically.
On Vertex, implicitly cached prefixes expire within 24 hours and most expire earlier. On supported models, durable storage can preserve a prefix after it is evicted from memory. For example, Vertex lists durable caching for Gemini 3.8 Flash, while Gemini 3.1 Pro Preview appears on its in-memory list. Vertex lets you disable durable caching while keeping in-memory caching, or disable implicit caching altogether.
Use the implicit-cache minimum published for the API you call. For example, a 5,000-token input meets the Developer API’s published minimum for Gemini 3.8 Flash but falls short of Vertex’s 6,144-token minimum. Meeting the minimum makes the request eligible for reuse, which still depends on a matching prefix being available.
| Model | Gemini Developer API implicit minimum | Vertex implicit minimum |
|---|---|---|
| Gemini 4 family (Carbon, Argon, Neon, Hydrogen) | 4,096 | 4,096 |
| Gemini 3.8 Flash | 4,096 | 6,144 |
| Gemini 3.6 Flash | 4,096 | 4,096 |
| Gemini 3.1 Pro Preview | 4,096 | 6,144 |
| Gemini 2.5 Flash and 2.5 Pro | 2,048 | 2,048 |
Vertex also lists a 6,144-token implicit minimum for Gemini 3.0 Flash Preview and Gemini 3.7 Flash. When moving a workload between surfaces, recheck the minimum and rerun your hit-rate measurement even if you keep the same model name and prompt.
Two behavioral rules deserve attention if you run agent loops:
- Gemini’s tips for hits are to put large, common content at the beginning of the prompt and to send similar-prefix requests in a short amount of time. Consistent with a best-effort cache, nothing on the page promises retention.
- The Developer API guide describes a Gemini 4 multi-turn rule. Gemini caches the full previous request only if the new request adds at least 2,050 tokens, counting model output, thought, and function results. For smaller additions, the last 2,050 tokens of the previous request are reprocessed at the standard input rate. Check billed input on short follow-ups even if most of the history remains eligible for reuse.
Read usage.total_cached_tokens in the Interactions API’s Python or JavaScript response. On Vertex, read cachedContentTokenCount in the response metadata. Track both cached and total input tokens across the comparison window.
Explicit caching: a managed object with a TTL you control
On Vertex, check the model’s explicit-cache support and minimum, create the cache, and reference its resource name on each reuse. Vertex documents a 60-minute default TTL, a one-minute minimum, no maximum cache duration, and a 10 MB limit for blob or text content. If the cache references a Cloud Storage object, keep that object unchanged until the cache expires or is deleted. For a changing corpus, store the next revision as a separate object so the original can continue serving requests that reference its cache.
An explicit object lets you identify the exact corpus a request reads, from a repository snapshot to a specific document revision. Keep the shared content in the object and send each request’s question separately. Vertex applies the cache discount to input that references an existing object. Implicit caching can also cache content beyond what you explicitly declared. To prevent cache data retention on Vertex, Google says to disable implicit caching and avoid creating explicit caches.
As of November 30, 2026, the Gemini Developer API documents explicit caching for supported Gemini 3 and 2.5 models through generateContent. The Interactions API supports implicit caching only. Separately, Vertex says Gemini 4 Hydrogen and later will gain TTL configuration on January 12, 2027, with default writes billed at 1.25× standard input and longer retention costing more. Use Vertex’s applicable prices when estimating that configuration.
On supported Gemini routes in LiteLLM, Anthropic-style cache_control can create a billable cachedContents object. LiteLLM sends the marked content to the cache API and passes the returned ID as cachedContent in the Gemini request. Inspect gateway-injected markers before comparing costs. Otherwise, a test you expected to use implicit caching can include explicit storage charges.
What Google charges for storage and reads
The storage rates below are the committed figures in our dataset, recorded from the Gemini API pricing page on 2026-06-12. The cached-read column uses the same committed data.
| Model | Cached read, USD per 1M | Storage, USD per 1M tokens per hour |
|---|---|---|
| gemini-3.5-flash | 0.15 | 1.00 |
| gemini-3.1-flash-lite | 0.025 (text) | 1.00 |
| gemini-3-flash-preview | 0.05 | 1.00 |
| gemini-3.1-pro-preview | 0.20 (prompts up to 200k) | 4.50 |
The November 30, 2026 Gemini Developer API pricing snapshot lists the following Standard paid-tier cached-read prices in USD per million tokens. Storage rates are USD per million tokens per hour.
- Gemini 3.8 Flash: cached read $0.075 through 2026-12-31, then $0.15 from 2027-01-01; storage $0.50 per 1M tokens per hour through 2026-12-31, then $1.00.
- Gemini 4 Carbon and Argon: cached read $0.10 through 2026-11-30, then $0.20 from 2026-12-01. The Developer API snapshot lists implicit caching for these models.
- Gemini 4 Neon reads at $0.15 and Hydrogen at $0.075.
- Starting December 1, 2026, Google says Developer API requests to
gemini-2.5-prowill route to Gemini 3.8 Flash, and requests togemini-2.5-flashwill route to Gemini 3.5 Flash-Lite. Each bills at the destination model’s rates.
Check current rates on the AI Provider Pricing Index before budgeting for either mechanism.
Break-even: when paying for storage makes sense
Compare the same model, prefix, and traffic window on both paths. Assuming both paths pay the same initial input charge, an explicit cache of T tokens held for H hours costs T / 1,000,000 × storage rate × H to store. Each later full-prefix read that would have missed implicitly saves T / 1,000,000 × (uncached input rate − cached read rate) when both paths have the same cached read rate. Add any extra cache creation charges to the explicit side.
These estimates use committed prices and assume one hour of storage.
- gemini-3.5-flash with a 300,000-token corpus. Storage costs
0.30 × $1.00 = $0.30. Each full-prefix implicit miss avoided saves0.30 × ($1.50 − $0.15) = $0.405. Break-even is about 0.74 such reads in that hour, so one full-prefix miss avoided covers storage. - gemini-3.1-pro-preview with a 150,000-token corpus. Assume total prompts of at most 200,000 tokens. Storage costs
0.15 × $4.50 = $0.675. Each full-prefix implicit miss avoided saves0.15 × ($2.00 − $0.20) = $0.27. Break-even is 2.5 such reads, so three cover storage. If the full request crosses 200,000 tokens, check the input and cached-read rates for that tier before estimating.
Measure implicit hits on representative traffic first. If every read in a burst already hits implicitly, explicit storage adds cost under these assumptions. If requests repeatedly miss, estimate how many of those misses an object held for the planned TTL would prevent. Include idle hours, especially when a job runs intermittently.
For partial hits, estimate savings from the extra tokens the explicit path would read at the cached rate. If implicit caching already reuses part of the document, subtract those tokens before applying the difference between input and read prices. To test this, hold the corpus revision fixed and record how much input was cached on each request. On Vertex you can then repeat the same request pattern with the explicit object referenced by name and compare the change in cached input with the storage cost.
Keep the gaps between calls representative of production in both runs. A test that sends every question in quick succession can overstate implicit reuse for a workload that runs throughout the day. Measure from the first request through the last scheduled read and include the time the explicit object would sit idle. If the corpus changes during that window, estimate each revision separately. Replacing the cache adds a creation event and starts another storage interval, so use the expected reads for each revision when you compare costs.
How to choose
- Default to implicit. Put large shared content first and send similar requests close together. On Vertex, Google lists the same 90% read discount for implicit and explicit hits on supported Gemini 3 and 2.5 models.
- Pick explicit when measured misses justify the TTL. Set the TTL to cover the scheduled reads and include idle time in the estimate. Delete the cache when the job finishes.
- Bind the cache to a content revision. On Vertex, keep the referenced Cloud Storage object intact until its cache expires or is deleted.
- Verify model and API support. As of November 30, 2026, use
generateContentfor explicit caching on supported Developer API models. Use Vertex pricing for the separately announced Gemini 4 Hydrogen TTL configuration. - Watch proxy behavior. Check whether LiteLLM is translating injected
cache_controlmarkers into paid cache objects on your Gemini route. - Measure before and after. Use the cached-token counter for your API and see how to measure your prompt cache hit rate. For related trade-offs, see 5-minute vs 1-hour prompt cache TTL and how LLM providers price prompt caching. For the mechanics, see what prompt caching is.
Sources
- Context caching (Google AI for Developers, accessed 2026-11-30)
- Gemini Developer API pricing (Google AI for Developers, accessed 2026-11-30)
- Context caching overview (Google Cloud Documentation, accessed 2026-11-30)
- Prompt caching (LiteLLM, accessed 2026-11-30)
Interactive report
- Who Pays to Remember: Give four APIs the same repeated prompt and open the bill one line at a time. The read discount is only the first entry.
How this note was produced
Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.
Gemini Implicit vs Explicit Context Caching: When Storage Costs Are Worth It. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/gemini-implicit-vs-explicit-caching/