diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 3781400c79d..dd367e875de 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -20332,7 +20332,7 @@ "supports_image_size": false }, "gemini-2.5-flash-preview-09-2025": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, "litellm_provider": "vertex_ai-language-models", @@ -20512,7 +20512,7 @@ }, "gemini-2.5-flash-lite-preview-06-17": { "deprecation_date": "2025-11-18", - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 5e-07, "input_cost_per_token": 1e-07, "litellm_provider": "vertex_ai-language-models", @@ -22102,7 +22102,7 @@ "supports_image_size": false }, "gemini/gemini-2.5-flash-preview-09-2025": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "deprecation_date": "2026-02-17", "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, @@ -22151,7 +22151,7 @@ "supports_image_size": false }, "gemini/gemini-flash-latest": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, "litellm_provider": "gemini", @@ -22198,7 +22198,7 @@ "google_maps_grounding_cost_per_query": 0.025 }, "gemini/gemini-flash-lite-latest": { - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 3e-07, "input_cost_per_token": 1e-07, "litellm_provider": "gemini", @@ -22246,7 +22246,7 @@ }, "gemini/gemini-2.5-flash-lite-preview-06-17": { "deprecation_date": "2025-11-18", - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 5e-07, "input_cost_per_token": 1e-07, "litellm_provider": "gemini", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 3781400c79d..dd367e875de 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -20332,7 +20332,7 @@ "supports_image_size": false }, "gemini-2.5-flash-preview-09-2025": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, "litellm_provider": "vertex_ai-language-models", @@ -20512,7 +20512,7 @@ }, "gemini-2.5-flash-lite-preview-06-17": { "deprecation_date": "2025-11-18", - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 5e-07, "input_cost_per_token": 1e-07, "litellm_provider": "vertex_ai-language-models", @@ -22102,7 +22102,7 @@ "supports_image_size": false }, "gemini/gemini-2.5-flash-preview-09-2025": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "deprecation_date": "2026-02-17", "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, @@ -22151,7 +22151,7 @@ "supports_image_size": false }, "gemini/gemini-flash-latest": { - "cache_read_input_token_cost": 7.5e-08, + "cache_read_input_token_cost": 3e-08, "input_cost_per_audio_token": 1e-06, "input_cost_per_token": 3e-07, "litellm_provider": "gemini", @@ -22198,7 +22198,7 @@ "google_maps_grounding_cost_per_query": 0.025 }, "gemini/gemini-flash-lite-latest": { - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 3e-07, "input_cost_per_token": 1e-07, "litellm_provider": "gemini", @@ -22246,7 +22246,7 @@ }, "gemini/gemini-2.5-flash-lite-preview-06-17": { "deprecation_date": "2025-11-18", - "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost": 1e-08, "input_cost_per_audio_token": 5e-07, "input_cost_per_token": 1e-07, "litellm_provider": "gemini", diff --git a/tests/test_litellm/llms/gemini/test_cost_calculator.py b/tests/test_litellm/llms/gemini/test_cost_calculator.py index 1e70803d39e..f1d62800337 100644 --- a/tests/test_litellm/llms/gemini/test_cost_calculator.py +++ b/tests/test_litellm/llms/gemini/test_cost_calculator.py @@ -391,3 +391,52 @@ def test_map_traffic_type_to_service_tier( assert ( _map_traffic_type_to_service_tier(traffic_type) == expected_service_tier ) + + +@pytest.mark.parametrize( + "model,custom_llm_provider,expected_cache_read_cost", + [ + ("gemini/gemini-flash-latest", "gemini", 3e-08), + ("gemini/gemini-flash-lite-latest", "gemini", 1e-08), + ("gemini/gemini-2.5-flash-preview-09-2025", "gemini", 3e-08), + ("gemini/gemini-2.5-flash-lite-preview-06-17", "gemini", 1e-08), + ("vertex_ai/gemini-2.5-flash-preview-09-2025", "vertex_ai", 3e-08), + ("vertex_ai/gemini-2.5-flash-lite-preview-06-17", "vertex_ai", 1e-08), + ], +) +def test_flash_alias_cache_read_is_ten_percent_of_input( + monkeypatch, model, custom_llm_provider, expected_cache_read_cost +): + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") + monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url="")) + + model_info = litellm.get_model_info( + model=model, custom_llm_provider=custom_llm_provider + ) + + assert model_info["cache_read_input_token_cost"] == expected_cache_read_cost + assert model_info["cache_read_input_token_cost"] == pytest.approx( + 0.10 * model_info["input_cost_per_token"] + ) + + +@pytest.mark.parametrize( + "prefixed,bare", + [ + ("gemini/gemini-flash-latest", "gemini-flash-latest"), + ("gemini/gemini-flash-lite-latest", "gemini-flash-lite-latest"), + ], +) +def test_flash_latest_alias_spellings_price_identically(monkeypatch, prefixed, bare): + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") + monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url="")) + + prefixed_entry = litellm.model_cost[prefixed] + bare_entry = litellm.model_cost[bare] + + for cost_key in ( + "input_cost_per_token", + "output_cost_per_token", + "cache_read_input_token_cost", + ): + assert prefixed_entry[cost_key] == bare_entry[cost_key]