feat(vertex_ai): multi-region Vertex hosts (aiplatform.*.rep.googleapis.com) - #26281
Conversation
Greptile SummaryThis PR adds support for Vertex AI multi-region endpoints ( Confidence Score: 5/5Safe to merge — the change is minimal, backward-compatible, and well-tested with mocked unit tests. All remaining findings are P2 (style/test-coverage suggestions). The core routing logic is correct, existing behavior is preserved, the WebSocket host derivation is simplified by reusing the helper, and the new test classes exercise all four location categories. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/vertex_ai/common_utils.py | Adds multi-region branch ("-" not in vertex_location) to get_vertex_base_url; logic is minimal and backward-compatible |
| litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py | Mirrors the same multi-region branch in the local get_vertex_base_url (trailing-slash variant) and simplifies the WebSocket host derivation by reusing it |
| tests/test_litellm/llms/vertex_ai/test_vertex_global_url_support.py | Adds us and eu parametrized cases to the existing TestVertexBaseURL suite; all tests are mocked, no network calls |
| tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py | Adds a new TestVertexPassthroughGetVertexBaseUrl class covering base URL and WebSocket host stripping for all four location types |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[vertex_location input] --> B{equals global?}
B -- Yes --> C["https://aiplatform.googleapis.com"]
B -- No --> D{is None?}
D -- Yes --> E[raise ValueError]
D -- No --> F{passes format regex?}
F -- No --> G[raise ValueError]
F -- Yes --> H{contains a dash?}
H -- No --> I["multi-region: aiplatform.geo.rep.googleapis.com\nus, eu, ..."]
H -- Yes --> J["regional: region-aiplatform.googleapis.com\nus-central1, europe-west1, ..."]
Reviews (2): Last reviewed commit: "fix(vertex_ai): use aiplatform.{geo}.rep..." | Re-trigger Greptile
mateo-berri
left a comment
There was a problem hiding this comment.
LGTM. Appreciate it!
…ion locations
Vertex multi-region endpoints (e.g. us, eu) use the rep host pattern, not
{geo}-aiplatform.googleapis.com. Regional IDs still contain a hyphen.
common_utils.get_vertex_base_url centralizes the rule for SDK/API URL building.
Proxy pass-through duplicates the same branching in a local get_vertex_base_url
(with trailing slashes) to avoid importing from common_utils there; live
WebSocket passthrough uses the same multi-region host logic for wss://.
Tests cover us/eu for the common_utils helper.
Made-with: Cursor
b9667ad to
3bc8338
Compare
Low: No security issues foundThis PR adds multi-region Vertex AI host support by branching on whether Status: 0 open Posted by Veria AI · 2026-04-23T22:14:57.488Z |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ion locations (BerriAI#26281) Vertex multi-region endpoints (e.g. us, eu) use the rep host pattern, not {geo}-aiplatform.googleapis.com. Regional IDs still contain a hyphen. common_utils.get_vertex_base_url centralizes the rule for SDK/API URL building. Proxy pass-through duplicates the same branching in a local get_vertex_base_url (with trailing slashes) to avoid importing from common_utils there; live WebSocket passthrough uses the same multi-region host logic for wss://. Tests cover us/eu for the common_utils helper. Made-with: Cursor
Relevant issues
Fixes #25926
Reference: Multi-region endpoints for Claude on Vertex AI (Google Cloud Blog)
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
✅ Test
Changes
litellm/llms/vertex_ai/common_utils.py—get_vertex_base_url: Afterglobal, treat locations that are truthy and contain no-as Vertex multi-region hosts (https://aiplatform.{geo}.rep.googleapis.com). Otherwise keep the regional patternhttps://{region}-aiplatform.googleapis.com(preserves prior behavior forNone/ empty via the final branch).litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py: Localget_vertex_base_urlduplicates the same rules with trailing slashes for URL joining (no import fromcommon_utils). WebSocket upstream host for Vertex live passthrough uses the same multi-region vs regional logic sous/euwork forwss://.tests/test_litellm/llms/vertex_ai/test_vertex_global_url_support.py: Parametrizeusandeuexpected base URLs forget_vertex_base_url.