From 2303379c2080aaeca398a7a3d3b8f5ac2019cc60 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 19 Sep 2026 00:07:22 -0700 Subject: [PATCH] fix(gemini): keep the 2048 cache minimum on Gemini 2.5 Pro only, per Google's live cachedContents API --- litellm/model_prices_and_context_window_backup.json | 2 -- model_prices_and_context_window.json | 2 -- .../context_caching/test_vertex_ai_context_caching.py | 11 ++++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index fcdf6c4baa3..de387552a44 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -25066,7 +25066,6 @@ "supports_parallel_function_calling": true, "supports_pdf_input": true, "supports_prompt_caching": true, - "prompt_cache_min_tokens": 2048, "supports_reasoning": true, "supports_response_schema": true, "supports_system_messages": true, @@ -27139,7 +27138,6 @@ "supports_parallel_function_calling": true, "supports_pdf_input": true, "supports_prompt_caching": true, - "prompt_cache_min_tokens": 2048, "supports_reasoning": true, "supports_response_schema": true, "supports_system_messages": true, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index fcdf6c4baa3..de387552a44 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -25066,7 +25066,6 @@ "supports_parallel_function_calling": true, "supports_pdf_input": true, "supports_prompt_caching": true, - "prompt_cache_min_tokens": 2048, "supports_reasoning": true, "supports_response_schema": true, "supports_system_messages": true, @@ -27139,7 +27138,6 @@ "supports_parallel_function_calling": true, "supports_pdf_input": true, "supports_prompt_caching": true, - "prompt_cache_min_tokens": 2048, "supports_reasoning": true, "supports_response_schema": true, "supports_system_messages": true, diff --git a/tests/test_litellm/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py b/tests/test_litellm/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py index 5c33b9a995b..7cbfacfc338 100644 --- a/tests/test_litellm/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py +++ b/tests/test_litellm/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py @@ -1396,14 +1396,15 @@ class TestContextCachingEndpoints: # Restart the patcher so teardown_method can stop it cleanly self._token_check_patcher.start() - @pytest.mark.parametrize("model", ["gemini-2.5-flash", "gemini-2.5-pro"]) - def test_check_and_create_cache_skips_between_default_and_gemini_2_5_minimum( - self, model, local_model_cost_map + def test_check_and_create_cache_skips_between_default_and_gemini_2_5_pro_minimum( + self, local_model_cost_map ): - """Gemini 2.5 Flash and Pro need 2048 cached tokens, twice the provider-agnostic default. + """Gemini 2.5 Pro needs 2048 cached tokens, twice the provider-agnostic default. - Content between the two used to reach Google's cachedContents endpoint and 400. + Content between the two used to reach Google's cachedContents endpoint and 400 + with "Cached content is too small". """ + model = "gemini-2.5-pro" self._token_check_patcher.stop() cached_messages = [