Skip to content

feat(vertex_ai): multi-region Vertex hosts (aiplatform.*.rep.googleapis.com) - #26281

Merged
ishaan-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_vertex_multiregion_base_url
Apr 23, 2026
Merged

feat(vertex_ai): multi-region Vertex hosts (aiplatform.*.rep.googleapis.com)#26281
ishaan-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_vertex_multiregion_base_url

Conversation

@milan-berri

Copy link
Copy Markdown
Collaborator

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

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • 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
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • 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.pyget_vertex_base_url: After global, treat locations that are truthy and contain no - as Vertex multi-region hosts (https://aiplatform.{geo}.rep.googleapis.com). Otherwise keep the regional pattern https://{region}-aiplatform.googleapis.com (preserves prior behavior for None / empty via the final branch).
  • litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py: Local get_vertex_base_url duplicates the same rules with trailing slashes for URL joining (no import from common_utils). WebSocket upstream host for Vertex live passthrough uses the same multi-region vs regional logic so us / eu work for wss://.
  • tests/test_litellm/llms/vertex_ai/test_vertex_global_url_support.py: Parametrize us and eu expected base URLs for get_vertex_base_url.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for Vertex AI multi-region endpoints (aiplatform.{geo}.rep.googleapis.com) by detecting single-token locations (no -) that are not global and routing them to the .rep. host pattern. The feature covers both the SDK path (common_utils.get_vertex_base_url) and the proxy pass-through + WebSocket paths in llm_passthrough_endpoints.py, with unit tests for both.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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, ..."]
Loading

Reviews (2): Last reviewed commit: "fix(vertex_ai): use aiplatform.{geo}.rep..." | Re-trigger Greptile

Comment thread litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@milan-berri
milan-berri force-pushed the litellm_vertex_multiregion_base_url branch from b9667ad to 3bc8338 Compare April 23, 2026 22:13
@milan-berri
milan-berri temporarily deployed to integration-postgres April 23, 2026 22:13 — with GitHub Actions Inactive
@milan-berri
milan-berri temporarily deployed to integration-postgres April 23, 2026 22:13 — with GitHub Actions Inactive
@milan-berri
milan-berri temporarily deployed to integration-postgres April 23, 2026 22:13 — with GitHub Actions Inactive
@milan-berri
milan-berri temporarily deployed to integration-postgres April 23, 2026 22:13 — with GitHub Actions Inactive
@milan-berri
milan-berri temporarily deployed to integration-postgres April 23, 2026 22:13 — with GitHub Actions Inactive
@veria-ai

veria-ai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Low: No security issues found

This PR adds multi-region Vertex AI host support by branching on whether vertex_location contains a hyphen. Both get_vertex_base_url functions (in common_utils.py and llm_passthrough_endpoints.py) apply a strict regex validation (^[a-z][a-z0-9-]*$) before interpolating the location into URLs, and all generated URLs remain under googleapis.com. The websocket path also routes through the same validated function. No new attack surface is introduced.


Status: 0 open
Risk: 2/10

Posted by Veria AI · 2026-04-23T22:14:57.488Z

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ishaan-berri
ishaan-berri merged commit b6d0f6b into litellm_internal_staging Apr 23, 2026
101 checks passed
@ishaan-berri
ishaan-berri deleted the litellm_vertex_multiregion_base_url branch April 23, 2026 22:58
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…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
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.

Vertex AI multi-region endpoints (us/eu) not supported — wrong base URL constructed

3 participants