diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 1942bc850f1..4b1c6465710 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -104,19 +104,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/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 1c6d5e0b28b..ce0a4c421f7 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -23499,6 +23499,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/model_prices_and_context_window.json b/model_prices_and_context_window.json index 1c6d5e0b28b..ce0a4c421f7 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -23499,6 +23499,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 d1d751989ea..4cb9301dd4b 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 @@ -664,10 +664,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 @@ -676,11 +674,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"), @@ -711,6 +708,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", "us-central1"), + ], +) +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 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."""