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(ptu): zero the Maps grounding rate on PTU deployments

mateo-berri31f0d82f00d9
diff --git a/litellm/litellm_core_utils/ptu_pricing.py b/litellm/litellm_core_utils/ptu_pricing.py
index 021210d9175..f545ba4aa3b 100644
--- a/litellm/litellm_core_utils/ptu_pricing.py
+++ b/litellm/litellm_core_utils/ptu_pricing.py
@@ -28,6 +28,7 @@ PTU_ZEROED_PRICING_FIELDS: Final = tuple(f for f in MirroredPricingParams.model_
"cache_creation_input_token_cost_above_1hr",
"cache_creation_input_token_cost_above_200k_tokens",
"cache_read_input_token_cost_above_200k_tokens",
+ "google_maps_grounding_cost_per_query",
)
# tiered_pricing is emptied rather than zeroed: its tiers outrank the zeros written beside
# them, so a zero here would leave the cost map's tiers billing the traffic the reserved
diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.py
index 7654622c8b8..9ea0796b680 100644
--- a/litellm/proxy/management_endpoints/model_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/model_management_endpoints.py
@@ -358,9 +358,10 @@ def _validate_ptu_model_info(model_info: Mapping[str, object]) -> None:
raise HTTPException(status_code=400, detail=error)
-# The mirrored per-token pricing fields plus the three remaining fields
-# Router._inherit_builtin_cache_pricing back-fills from the public cost map. An unset field is
-# what that back-fill targets, so a field left out here is one a PTU deployment still bills.
+# The mirrored per-token pricing fields plus the remaining rates the public cost map or a
+# provider default would otherwise supply (the cache back-fills, the Maps grounding rate). An
+# unset field falls back to those sources, so a field left out here is one a PTU deployment
+# still bills.
# tiered_pricing is the one mirrored field that is a table of ranges, not a rate, so it is stored
# empty (see _PTU_EMPTIED_PRICING_FIELDS): its tiers outrank the zeros written beside them, so
# dropping it would leave the cost map's tiers billing the traffic the reserved capacity covers.
diff --git a/tests/test_litellm/litellm_core_utils/test_ptu_pricing.py b/tests/test_litellm/litellm_core_utils/test_ptu_pricing.py
index f5339daad20..b8fb372d537 100644
--- a/tests/test_litellm/litellm_core_utils/test_ptu_pricing.py
+++ b/tests/test_litellm/litellm_core_utils/test_ptu_pricing.py
@@ -134,6 +134,15 @@ def test_the_search_context_table_is_zeroed_in_place_on_every_deployment():
assert dict(override[field]) == dict.fromkeys(SEARCH_CONTEXT_SIZES, 0.0)
+def test_the_maps_grounding_rate_is_zeroed_on_every_deployment():
+ """An absent rate falls back to the Maps default rather than free, so it is written
+ even when the deployment never declared one."""
+ override = _with_flag(_VALID)
+
+ assert override is not None
+ assert override["google_maps_grounding_cost_per_query"] == 0.0
+
+
def test_a_declared_table_does_not_become_a_scalar():
"""Zeroing it as a plain 0.0 would leave the provider's reader without a table to
consult, which is the same as absent."""