Context caching | Gemini API | Google AI for Developers
In a typical AI workflow, you might pass the same input tokens over and over to a model. The Gemini API offers two different caching mechanisms: Implicit caching is enabled on Gemini 2.5 models by default. If a request contains content that is a cache hit, we automatically pass the cost savings back to you. Explicit caching is useful in cases where you want to guarantee cost savings, but with some added developer work. Implicit caching is enabled by default for all Gemini 2.5 models. We automatically pass on cost savings if your request hits caches. There is nothing you need to do in order to enable this. It is effective as of May 8th, 2025. The minimum input token count for context caching is 1,024 for 2.5 Flash and 2,048 for 2.5 Pro. To increase the chance of an implicit cache hit: You can see the number of tokens which were cache hits in the response object's usage_metadata field. Using the Gemini API explicit caching feature, you can pass some content to the model once, cache the i
The Interactions API is now generally available. We recommend using this API for access to all the latest features and models. Home Gemini API Docs Send feedback Context caching In a typical AI workflow, you might pass the same input tokens over and over to a model. The Gemini API offers implicit caching to optimize performance and costs. Note: This version of the page covers the Interactions API , which only supports implicit caching. Explicit caching (manually creating and managing cache objects) is not supported in the Interactions API. You can use the toggle on this page to switch to the g
Explore this link on the map →related reading
- GitHub - brexhq/prompt-engineering: Tips and tricks for working with Large Language Models like OpenAI's GPT-4. · GitHubgithub.com
- AI Model & API Providers Analysis | Artificial Analysisartificialanalysis.ai
- Cookbookcookbook.openai.com
- OpenAI | Research & Deploymentopenai.com
- KV Caching Explained: Optimizing Transformer Inference Efficiencyhuggingface.co
- API Overview | OpenAI API Referenceplatform.openai.com
- GitHub - google-gemini/cookbook: Examples and guides for using the Gemini API · GitHubgithub.com
- GitHub - mem0ai/mem0: Universal memory layer for AI Agents · GitHubgithub.com
- GitHub - x1xhlol/system-prompts-and-models-of-ai-tools: FULL Augment Code, Claude Code, Cluely, CodeBuddy, Comet, Cursor, Devin AI, Junie, Kiro, Leap.new, Lovable, Manus, NotionAI, Orchids.app, Perplexity, Poke, Qoder, Replit, Same.dev, Tragithub.com
- GitHub - affaan-m/ECC: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. · GitHubgithub.com
- GitHub - karpathy/nanochat: The best ChatGPT that $100 can buy. · GitHubgithub.com
- GitHub - f/prompts.chat: f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy. · GitHubgithub.com