--- url: "https://ai.google.dev/gemini-api/docs/caching" titulek: "Context caching | Gemini API | Google AI for Developers" h1: "Context caching" popis: "Learn how to use Context Caching in the Interactions API" jazyk: "en" kanonicka: "https://ai.google.dev/gemini-api/docs/caching" drobecky: ["Gemini API", "Context caching"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 06:16:46" znaku: 1692 slov: 249 kodovani: "iso-8859-2" sha256: "b4c86be6f3cf586847a1009fe2e744e0d324796e5fe571fecd0a86db1413cca2" --- 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. Implicit caching Implicit caching is enabled by default for all Gemini 2.5 and newer models. It is supported for both [stateful](/gemini-api/docs/text-generation#multi-turn-conversations) (using `previous_interaction_id`) and [stateless](/gemini-api/docs/text-generation#stateless-conversations) conversation modes. We automatically pass on cost savings if your request hits caches. There is nothing you need to do in order to enable this. The minimum input token count for context caching is listed in the following table for each model: Model Min token limit Gemini 3.8 Flash 4,096 Gemini 3.7 Flash 4,096 Gemini 3.6 Flash 4,096 Gemini 3.5 Flash 4,096 Gemini 3.1 Pro Preview 4,096 Gemini 2.5 Flash 2,048 Gemini 2.5 Pro 2,048 To increase the chance of an implicit cache hit: Try putting large and common contents at the beginning of your prompt Try to send requests with similar prefix in a short amount of time You can see the number of tokens which were cache hits in the response object's `usage.total_cached_tokens` (Python and JavaScript) field. Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-09-02 UTC.