diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 6cff9729189..cfb385f5f95 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -112,19 +112,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 cb9bfa6ffe4..99b380110fa 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -30216,6 +30216,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_parallel_function_calling": true, @@ -30284,6 +30289,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_minimal_reasoning_effort": false, @@ -76358,6 +76368,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_minimal_reasoning_effort": false, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index cb9bfa6ffe4..99b380110fa 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -30216,6 +30216,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_parallel_function_calling": true, @@ -30284,6 +30289,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_minimal_reasoning_effort": false, @@ -76358,6 +76368,11 @@ "supported_output_modalities": [ "text" ], + "supported_regions": [ + "global", + "us", + "eu" + ], "supports_audio_input": true, "supports_function_calling": true, "supports_minimal_reasoning_effort": false, diff --git a/tests/unit/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/unit/llms/vertex_ai/test_vertex_ai_common_utils.py index 152ab2ffc13..471c1873da4 100644 --- a/tests/unit/llms/vertex_ai/test_vertex_ai_common_utils.py +++ b/tests/unit/llms/vertex_ai/test_vertex_ai_common_utils.py @@ -1069,10 +1069,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 @@ -1081,11 +1079,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"), @@ -1112,6 +1109,32 @@ def test_get_vertex_region_global_only_model(model_cost_entry, vertex_region, ex assert result == expected_region +@pytest.mark.parametrize("model", ["gemini-3.7-flash", "gemini-3.8-flash", "gemini-4-argon"]) +@pytest.mark.parametrize( + "vertex_region, expected_region", + [ + (None, "global"), + ("global", "global"), + ("us", "us"), + ("eu", "eu"), + ("us-central1", "us-central1"), + ("europe-west1", "europe-west1"), + ], +) +def test_gemini_defaults_to_global_and_preserves_explicit_regions( + model: str, vertex_region: str | None, expected_region: str +) -> None: + """Location availability verified 2026-10-19: + + https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-7-flash + https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-8-flash + https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-argon + """ + from litellm.llms.vertex_ai.vertex_llm_base import VertexBase + + assert VertexBase.get_vertex_region(vertex_region=vertex_region, model=model) == expected_region + + def test_vertex_filter_format_uri(): import json diff --git a/tests/unit/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py b/tests/unit/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py index 85a2124ab02..5d677506bf4 100644 --- a/tests/unit/llms/vertex_ai/vertex_ai_partner_models/gemma/test_vertex_ai_gemma_global_endpoint.py +++ b/tests/unit/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/unit/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py b/tests/unit/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py index 4a11c84a96d..c5031e259da 100644 --- a/tests/unit/llms/vertex_ai/vertex_ai_partner_models/qwen/test_vertex_ai_qwen_global_endpoint.py +++ b/tests/unit/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."""