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(vertex_ai): support model names with slashes in passthrough URLs (#19944)

michelligabrieleea3853e9772f
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py
index 152b99ca4db..a0e2ddf5e98 100644
--- a/litellm/llms/vertex_ai/common_utils.py
+++ b/litellm/llms/vertex_ai/common_utils.py
@@ -849,7 +849,7 @@ def get_vertex_model_id_from_url(url: str) -> Optional[str]:
`https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL_ID}:streamGenerateContent`
"""
- match = re.search(r"/models/([^/:]+)", url)
+ match = re.search(r"/models/([^:]+)", url)
return match.group(1) if match else None
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 953f54e4a54..94323e06901 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
@@ -812,6 +812,36 @@ def test_get_vertex_model_id_from_url():
assert model_id is None
+def test_get_vertex_model_id_from_url_with_slashes():
+ """Test get_vertex_model_id_from_url with model names containing slashes (e.g., gcp/google/gemini-2.5-flash)
+
+ Regression test for NVIDIA issue: custom model names with slashes in passthrough URLs
+ were being truncated (e.g., 'gcp/google/gemini-2.5-flash' -> 'gcp'), causing access_groups
+ checks to fail.
+ """
+ from litellm.llms.vertex_ai.common_utils import get_vertex_model_id_from_url
+
+ # Test with model name containing slashes: gcp/google/gemini-2.5-flash
+ url = "https://us-central1-aiplatform.googleapis.com/v1/projects/test-project/locations/us-central1/publishers/google/models/gcp/google/gemini-2.5-flash:generateContent"
+ model_id = get_vertex_model_id_from_url(url)
+ assert model_id == "gcp/google/gemini-2.5-flash"
+
+ # Test with model name containing slashes: gcp/google/gemini-3-flash-preview
+ url = "https://us-central1-aiplatform.googleapis.com/v1/projects/test-project/locations/global/publishers/google/models/gcp/google/gemini-3-flash-preview:streamGenerateContent"
+ model_id = get_vertex_model_id_from_url(url)
+ assert model_id == "gcp/google/gemini-3-flash-preview"
+
+ # Test with custom model path: custom/model
+ url = "https://us-central1-aiplatform.googleapis.com/v1/projects/test-project/locations/us-central1/publishers/google/models/custom/model:generateContent"
+ model_id = get_vertex_model_id_from_url(url)
+ assert model_id == "custom/model"
+
+ # Test passthrough URL format (without host)
+ url = "v1/projects/my-project/locations/us-central1/publishers/google/models/gcp/google/gemini-2.5-flash:generateContent"
+ model_id = get_vertex_model_id_from_url(url)
+ assert model_id == "gcp/google/gemini-2.5-flash"
+
+
def test_construct_target_url_with_version_prefix():
"""Test construct_target_url with version prefixes"""
from litellm.llms.vertex_ai.common_utils import construct_target_url