Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(model_prices): correct gemini-3.5-flash-lite flex cache-read pricing

mateo-berri0243c5dee487
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index a6da2c1fb09..cead28e18aa 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -20147,7 +20147,7 @@
"gemini-3.5-flash-lite": {
"deprecation_date": "2027-07-21",
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
@@ -22488,7 +22488,7 @@
},
"gemini/gemini-3.5-flash-lite": {
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
@@ -41987,7 +41987,7 @@
"vertex_ai/gemini-3.5-flash-lite": {
"deprecation_date": "2027-07-21",
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index a6da2c1fb09..cead28e18aa 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -20147,7 +20147,7 @@
"gemini-3.5-flash-lite": {
"deprecation_date": "2027-07-21",
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
@@ -22488,7 +22488,7 @@
},
"gemini/gemini-3.5-flash-lite": {
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
@@ -41987,7 +41987,7 @@
"vertex_ai/gemini-3.5-flash-lite": {
"deprecation_date": "2027-07-21",
"cache_read_input_token_cost": 3e-08,
- "cache_read_input_token_cost_flex": 2e-08,
+ "cache_read_input_token_cost_flex": 1.5e-08,
"cache_read_input_token_cost_priority": 5e-08,
"input_cost_per_token": 3e-07,
"input_cost_per_token_batches": 1.5e-07,
diff --git a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py
index e13643ed6ce..18c3014c35d 100644
--- a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py
+++ b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py
@@ -3377,6 +3377,44 @@ def test_generic_cost_per_token_gemini_35_flash_lite(_local_model_cost_map):
assert completion_cost == pytest.approx(0.00125)
+GEMINI_35_FLASH_LITE_SERVICE_TIER_PRICING = [
+ (None, 3e-07, 2.5e-06, 3e-08),
+ ("flex", 1.5e-07, 1.25e-06, 1.5e-08),
+ ("priority", 5.4e-07, 4.5e-06, 5e-08),
+]
+
+
+ "service_tier,input_rate,output_rate,cache_read_rate", GEMINI_35_FLASH_LITE_SERVICE_TIER_PRICING
+)
+ "model",
+ ["gemini-3.5-flash-lite", "gemini/gemini-3.5-flash-lite", "vertex_ai/gemini-3.5-flash-lite"],
+)
+def test_gemini_35_flash_lite_service_tier_pricing(
+ model, service_tier, input_rate, output_rate, cache_read_rate, _local_model_cost_map
+):
+ """Regression: Vertex publishes flash-lite Flex/Batch context caching at $0.015/M
+ (1.5e-08/token), so flex cache reads must not be billed at the 2e-08 rate the map
+ used to carry."""
+ usage = Usage(
+ prompt_tokens=1_000,
+ completion_tokens=500,
+ total_tokens=1_500,
+ prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=200, text_tokens=800),
+ )
+
+ prompt_cost, completion_cost = generic_cost_per_token(
+ model=model.split("/")[-1],
+ usage=usage,
+ custom_llm_provider=model.split("/")[0] if "/" in model else "gemini",
+ service_tier=service_tier,
+ )
+
+ assert prompt_cost == pytest.approx(800 * input_rate + 200 * cache_read_rate, rel=1e-9)
+ assert completion_cost == pytest.approx(500 * output_rate, rel=1e-9)
+
+
@pytest.mark.parametrize(
"service_tier,input_rate,cache_read_rate,cache_write_rate,output_rate",
[