Skip to content

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

Closed
milan-berri wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
milan-berri:litellm_vertex_multiregion_base_url
Closed

feat(vertex_ai): multi-region Vertex hosts (aiplatform.*.rep.googleapis.com)#25959
milan-berri wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
milan-berri: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.

@vercel

vercel Bot commented Apr 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 17, 2026 3:08pm

Request Review

@codecov

codecov Bot commented Apr 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ass_through_endpoints/llm_passthrough_endpoints.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for Vertex AI multi-region endpoints (aiplatform.{geo}.rep.googleapis.com) by extending get_vertex_base_url in both common_utils.py and the passthrough module. The detection heuristic — a non-empty location string containing no - (and not equal to "global") — correctly distinguishes multi-region geographies (e.g. us, eu) from regional locations (e.g. us-central1). The previous review concerns around duplicate WebSocket logic and missing passthrough tests have both been resolved in this revision.

Confidence Score: 5/5

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

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; 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"]
Loading

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

Comment thread litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py Outdated
Comment thread tests/test_litellm/llms/vertex_ai/test_vertex_global_url_support.py
…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

Copy link
Copy Markdown
Collaborator Author

@greptileai - review again

@jamesseiwert

Copy link
Copy Markdown

@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
mateo-berri self-requested a review April 21, 2026 15:55

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

Can you run uv lock and commit the new lock file? Seems the tests are failing

@milan-berri

Copy link
Copy Markdown
Collaborator Author

re-created to run CI proprely here #26281

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