Skip to content

Conversation

@krisxia0506
Copy link

Title

fix(vertex_ai): improve passthrough endpoint url parsing and construction

Relevant issues

Fixes #17402

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory,
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
image

Type

🐛 Bug Fix

Changes

  1. litellm/llms/vertex_ai/common_utils.py:

    • Added get_vertex_model_id_from_url helper function to extract the model ID from Vertex AI URLs.
    • Updated construct_target_url to correctly handle and strip /v1/ and /v1beta1/ version prefixes from the requested route to prevent double versioning in the target URL.
  2. litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:

    • Updated _base_vertex_proxy_route to improve project and location resolution. If vertex_project or vertex_location cannot be parsed from the URL, it now attempts to extract the model ID and look up the corresponding deployment in the llm_router to find the configured vertex_project and vertex_location.
  3. tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py:

    • Added unit tests for get_vertex_model_id_from_url covering valid and invalid URLs.
    • Added unit tests for construct_target_url verifying correct handling of /v1/ and /v1beta1/ prefixes.

@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Dec 5, 2025 6:29am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: use_in_pass_through does not pass project/location to Vertex AI — project_name=None and location=None

1 participant