cached_content_token_count field is returned untouched — zero code changes.
The headline first: Gemini caching exists, but don’t count on it. Implicit cache behavior is controlled upstream, and real-world hit rates clearly trail OpenAI and Claude. Treat it as a nice-to-have bonus and always estimate costs at the uncached price.
This page is based on the official Google documentation (ai.google.dev/gemini-api/docs/caching, as of June 2026).
The Mechanism in One Sentence
When a request’s opening segment (prefix) matches a recent request and meets the minimum length, the upstream reuses its cache automatically: the matched portion bills at the official discount (officially up to 90% off), no markers needed.Trigger Conditions
Note Gemini’s caching threshold (4096) is much higher than OpenAI’s (1024) — short system prompts essentially never hit on Gemini, one reason Gemini caching feels underwhelming.
How to Confirm a Hit
Checkusage_metadata.cached_content_token_count:
usageMetadata.cachedContentTokenCount.
Raising Your Odds
The playbook is the same as OpenAI’s (full explanation in the OpenAI Cache Billing Guide):- Stable content first: long system instructions, documents, few-shot examples up front; user input and timestamps last
- Make the prefix long: anything under 4096 tokens (Gemini 3 series) never hits
- Cluster reuse in time: send batch jobs back to back, don’t space them out
- Multi-turn chats are naturally append-only prefixes and hit more easily
Explicit Caching (cachedContents)
Google also offers an explicit caching API (cachedContents — create a TTL’d cache object and reference it). That is a stateful server-side resource and is not currently supported on the APIYI channel; use implicit caching.
Versus Other Channels
For cache-sensitive workloads with long, frequent prefixes (agents, RAG, batch documents), prefer the OpenAI or Claude channels. Platform-wide cache support overview: Cache Billing FAQ.
Related Links
- This group: Native Calls · Multimodal & Code Execution · Function Calling
- Other channels: OpenAI Cache Billing · Claude Cache Billing
- Official Google docs:
ai.google.dev/gemini-api/docs/caching