From 5e2d2dd066e1092c9850142ed7522059d2085150 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Sat, 22 Aug 2026 18:24:21 -0700 Subject: [PATCH 1/3] fix(vertex_ai): add Gemini 3.7 Flash regions --- model_prices_and_context_window.json | 5 +++++ .../vertex_ai/test_vertex_ai_common_utils.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 3af7d9e5019..423624cb16c 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -20605,6 +20605,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_parallel_function_calling": true, diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py index cc923f05831..df5216c34d4 100644 --- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py +++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py @@ -695,6 +695,25 @@ def test_get_vertex_region_global_only_model( assert result == expected_region +@pytest.mark.parametrize( + "vertex_region, expected_region", + [ + (None, "global"), + ("global", "global"), + ("us", "us"), + ("eu", "eu"), + ("us-central1", "global"), + ], +) +def test_get_vertex_region_gemini_3_7_flash(vertex_region, expected_region): + from litellm.llms.vertex_ai.vertex_llm_base import VertexBase + + assert ( + VertexBase.get_vertex_region(vertex_region=vertex_region, model="gemini-3.7-flash") + == expected_region + ) + + def test_vertex_filter_format_uri(): import json From e05d99d345f738210563df8df8f9a8e58365b93d Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 28 Aug 2026 07:52:50 -0700 Subject: [PATCH 2/3] fix(vertex_ai): preserve explicit regions --- litellm/llms/vertex_ai/vertex_llm_base.py | 11 ----------- .../llms/vertex_ai/test_vertex_ai_common_utils.py | 11 ++++------- .../gemma/test_vertex_ai_gemma_global_endpoint.py | 4 ++-- .../qwen/test_vertex_ai_qwen_global_endpoint.py | 6 +++--- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 75098515deb..0e6e4bac08d 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -80,19 +80,8 @@ class VertexBase: supported_regions: Final = model_info.get("supported_regions") if supported_regions and len(supported_regions) > 0: - # If user didn't specify region, use the first supported region if vertex_region is None: return supported_regions[0] - # If user specified a region not supported by this model, override it - if vertex_region not in supported_regions: - verbose_logger.warning( - "Vertex AI model '%s' does not support region '%s' (supported: %s). Routing to '%s'.", - model, - vertex_region, - supported_regions, - supported_regions[0], - ) - return supported_regions[0] return vertex_region return vertex_region or "us-central1" diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py index df5216c34d4..b53b79a36a0 100644 --- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py +++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py @@ -648,10 +648,8 @@ def test_get_vertex_url_global_region(stream, expected_endpoint_suffix): [ # Model with supported_regions=["global"], no user region -> use "global" ({"supported_regions": ["global"]}, None, "global"), - # Model with supported_regions=["global"], user passes unsupported region -> override to "global" - ({"supported_regions": ["global"]}, "us-central1", "global"), - # Model with supported_regions=["global"], user passes unsupported region -> override to "global" - ({"supported_regions": ["global"]}, "europe-west1", "global"), + ({"supported_regions": ["global"]}, "us-central1", "us-central1"), + ({"supported_regions": ["global"]}, "europe-west1", "europe-west1"), # Model with supported_regions=["us-west2"], no user region -> use "us-west2" ({"supported_regions": ["us-west2"]}, None, "us-west2"), # Model with supported_regions=["us-west2", "us-central1"], user passes supported region -> respect it @@ -660,11 +658,10 @@ def test_get_vertex_url_global_region(stream, expected_endpoint_suffix): "us-central1", "us-central1", ), - # Model with supported_regions=["us-west2", "us-central1"], user passes unsupported region -> override ( {"supported_regions": ["us-west2", "us-central1"]}, "europe-west1", - "us-west2", + "europe-west1", ), # No model_cost entry, no user region -> default us-central1 ({}, None, "us-central1"), @@ -702,7 +699,7 @@ def test_get_vertex_region_global_only_model( ("global", "global"), ("us", "us"), ("eu", "eu"), - ("us-central1", "global"), + ("us-central1", "us-central1"), ], ) def test_get_vertex_region_gemini_3_7_flash(vertex_region, expected_region): diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py index 957d7475d91..5572e9a13d4 100644 --- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py +++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py @@ -105,7 +105,7 @@ class TestVertexBaseGetVertexRegionGemma: ) assert result == "global" - def test_global_model_with_unsupported_user_region_overrides(self): + def test_global_model_preserves_explicit_user_region(self): vertex_base = VertexBase() with patch.dict( @@ -121,7 +121,7 @@ class TestVertexBaseGetVertexRegionGemma: vertex_region="us-central1", model="google/gemma-4-26b-a4b-it-maas", ) - assert result == "global" + assert result == "us-central1" class TestCreateVertexURLGemma: diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py index 4a11c84a96d..c5031e259da 100644 --- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py +++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py @@ -64,8 +64,8 @@ class TestVertexBaseGetVertexRegion: ) assert result == "global" - def test_global_model_with_unsupported_user_region_overrides(self): - """Test that unsupported user region is overridden for global-only models.""" + def test_global_model_preserves_explicit_user_region(self): + """Test that an explicit user region is not silently broadened.""" vertex_base = VertexBase() with patch.dict( @@ -81,7 +81,7 @@ class TestVertexBaseGetVertexRegion: vertex_region="us-central1", model="qwen/qwen3-next-80b-a3b-instruct-maas", ) - assert result == "global" + assert result == "us-central1" def test_non_global_model_uses_provided_region(self): """Test that non-global models use the provided region.""" From cca5feafa0e3c55aea960860b7b64fefc7882784 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 28 Aug 2026 08:29:22 -0700 Subject: [PATCH 3/3] fix(model_cost): sync Gemini 3.7 regions to backup --- litellm/model_prices_and_context_window_backup.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 3af7d9e5019..423624cb16c 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -20605,6 +20605,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_parallel_function_calling": true,