feat(vertex_ai): multi-region Vertex hosts (aiplatform.*.rep.googleapis.com) - #25959
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds support for Vertex AI multi-region endpoints ( Confidence Score: 5/5Safe to merge — changes are minimal, backward-compatible, and well-tested with mocked unit tests covering all location types. All findings from the previous review round (duplicated WebSocket ternary, missing passthrough tests) have been addressed. The multi-region heuristic ("-" not in vertex_location, excluding global) is sound for current GCP region naming conventions. No regressions to None, empty string, or regional locations. All P2 or no-issue. 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; preserves prior behavior for None, empty string, and regional locations. |
| litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py | Mirrors multi-region logic in module-local get_vertex_base_url (with trailing slash); WebSocket handler now delegates to the helper instead of repeating inline ternary. |
| tests/test_litellm/llms/vertex_ai/test_vertex_global_url_support.py | Adds us and eu parametrized cases to TestVertexBaseURL; no real network calls, consistent with existing test patterns. |
| tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py | New TestVertexPassthroughGetVertexBaseUrl class covers both trailing-slash and WebSocket host-strip behavior for all four location types. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[vertex_location input] --> B{== 'global'?}
B -->|Yes| C["https://aiplatform.googleapis.com[/]"]
B -->|No| D{truthy AND no '-'?}
D -->|Yes - multi-region e.g. us, eu| E["https://aiplatform.{geo}.rep.googleapis.com[/]"]
D -->|No - regional or None| F["https://{location}-aiplatform.googleapis.com[/]"]
C --> G[WebSocket: strip https:// + trailing /]
E --> G
F --> G
G --> H["wss://{host}/ws/...BidiGenerateContent"]
Reviews (3): Last reviewed commit: "fix(vertex_ai): use aiplatform.{geo}.rep..." | Re-trigger Greptile
…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
192fd6d to
8a2d9e0
Compare
|
@greptileai - review again |
|
@milan-berri thank you for this! It is currently a blocker for us getting on opus-4-7. Looking forward to testing this |
mateo-berri
left a comment
There was a problem hiding this comment.
Can you run uv lock and commit the new lock file? Seems the tests are failing
|
re-created to run CI proprely here #26281 |
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.