flâneur — a map of the web's best reading

Context caching | Gemini API | Google AI for Developers

ai.google.dev · 253 words · saved by 1 readers

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