Skip to content

Vertex base url update#28145

Merged
DavidAPierce merged 4 commits into
mainfrom
vertex_baseUrl_update
Jun 25, 2026
Merged

Vertex base url update#28145
DavidAPierce merged 4 commits into
mainfrom
vertex_baseUrl_update

Conversation

@DavidAPierce

Copy link
Copy Markdown
Contributor

Summary

This PR addresses two critical items for developers and users running Gemini CLI with Vertex AI:

  1. Official Endpoint Routing: Routes default base URLs to Vertex AI official Representative Endpoints (REP) for the US and EU multi-regions when GOOGLE_CLOUD_LOCATION is set to 'us' or 'eu' respectively (and no explicit baseUrl is set).
  2. Improved Error Messaging for Model Availability: Enhances the handling of ModelNotFoundError (404) under Vertex AI by displaying detailed region-specific messages and pointing users to the official Google Cloud supported locations documentation page.

Details

1. Vertex AI Representative Endpoints (REP)

  • Currently, when using Vertex AI without an explicit baseUrl configured, the client dynamically constructs default legacy hostnames (e.g., 'us-aiplatform.googleapis.com') instead of routing to the official REP endpoints.
  • To resolve this, we introduced two constant endpoints in packages/core/src/core/contentGenerator.ts:
    • VERTEX_AI_US_REP_ENDPOINT = 'https://aiplatform.us.rep.googleapis.com'
    • VERTEX_AI_EU_REP_ENDPOINT = 'https://aiplatform.eu.rep.googleapis.com'
  • During createContentGenerator, we check the GOOGLE_CLOUD_LOCATION environment variable and if no envBaseUrl is present and config.authType === AuthType.USE_VERTEX_AI, we set the baseUrl to the corresponding US or EU REP endpoint if the location matches.

2. Region-Specific Model Availability Error Messaging

  • When a requested model is unavailable in the configured region, Vertex AI returns a ModelNotFoundError.
  • We updated packages/cli/src/ui/hooks/useQuotaAndFallback.ts to capture this specific scenario:
    • If the auth type is Vertex AI and the failed model is a valid Gemini model, we render a highly-informative, region-specific error message.
    • This message notifies the user that the model is unavailable in the given region and provides the official Google Cloud documentation link for supported locations: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations.

3. Unit Testing

  • Comprehensive unit tests have been added and verified:
    • Core Content Generator Tests: Added should use US REP endpoint for Vertex AI when location is us and no baseUrl is provided and should use EU REP endpoint for Vertex AI when location is eu and no baseUrl is provided in packages/core/src/core/contentGenerator.test.ts.
    • CLI Fallback Hook Tests: Added should handle ModelNotFoundError with Vertex AI by displaying region-specific availability message and documentation link and should handle ModelNotFoundError with Vertex AI and invalid model by displaying generic not found error message in packages/cli/src/ui/hooks/useQuotaAndFallback.test.ts.
    • Environmental isolation was improved in contentGenerator.test.ts to prevent leakage from any host machine's environment variables.

How to Validate

Run unit tests across packages:

npx vitest run packages/core/src/core/contentGenerator.test.ts packages/cli/src/ui/hooks/useQuotaAndFallback.test.ts

All 85 tests should pass successfully.

Local testing can be done via setting

export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT="<YOUR_PROJECT_ID>"
export GOOGLE_CLOUD_LOCATION="us"
unset GOOGLE_VERTEX_BASE_URL

for both a build including this change, and one without it to verify that gemini-3.5-flash models do not error with no set base vertex URL in this updated build.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@DavidAPierce DavidAPierce requested a review from a team as a code owner June 25, 2026 17:38
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Size Change: +1.07 kB (0%)

Total Size: 35.2 MB

Filename Size Change
./bundle/chunk-4EKTYONF.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-5SQK4GVR.js 0 B -661 kB (removed) 🏆
./bundle/chunk-5ZVBSTO3.js 0 B -13 kB (removed) 🏆
./bundle/chunk-6B4KXRJG.js 0 B -3.77 kB (removed) 🏆
./bundle/chunk-7RAU3IRD.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-IFYPE6C3.js 0 B -49.2 kB (removed) 🏆
./bundle/chunk-IMHTTZW4.js 0 B -16.2 MB (removed) 🏆
./bundle/chunk-UDUTNND5.js 0 B -3.65 MB (removed) 🏆
./bundle/core-TGZ4PX46.js 0 B -50 kB (removed) 🏆
./bundle/devtoolsService-CEEU2BUU.js 0 B -147 kB (removed) 🏆
./bundle/gemini-4NGCRZXW.js 0 B -1.04 MB (removed) 🏆
./bundle/interactiveCli-ZEVLBK5N.js 0 B -1.3 MB (removed) 🏆
./bundle/liteRtServerManager-KE4XSXVN.js 0 B -2.08 kB (removed) 🏆
./bundle/oauth2-provider-GBIUVF2T.js 0 B -9.12 kB (removed) 🏆
./bundle/chunk-BGO5P4SK.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-DJ2MAPA4.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/chunk-IFZBJAIS.js 3.77 kB +3.77 kB (new file) 🆕
./bundle/chunk-KDUSRIPR.js 16.2 MB +16.2 MB (new file) 🆕
./bundle/chunk-LI4X3MFD.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/chunk-LPV5O4RR.js 13 kB +13 kB (new file) 🆕
./bundle/chunk-N4NXCHFL.js 3.65 MB +3.65 MB (new file) 🆕
./bundle/chunk-SMPFUJKJ.js 661 kB +661 kB (new file) 🆕
./bundle/core-63JG4BA2.js 50 kB +50 kB (new file) 🆕
./bundle/devtoolsService-OONGO7KD.js 147 kB +147 kB (new file) 🆕
./bundle/gemini-3WJV7PXU.js 1.04 MB +1.04 MB (new file) 🆕
./bundle/interactiveCli-4MTE4M64.js 1.3 MB +1.3 MB (new file) 🆕
./bundle/liteRtServerManager-HL7U7X3U.js 2.08 kB +2.08 kB (new file) 🆕
./bundle/oauth2-provider-CI7EXFLX.js 9.12 kB +9.12 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-TUDYL3X4.js 40.3 kB 0 B
./bundle/cleanup-YO7RTYKH.js 0 B -902 B (removed) 🏆
./bundle/devtools-TYCPOPV3.js 683 kB 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/examples/hooks/scripts/on-start.js 188 B 0 B
./bundle/examples/mcp-server/example.js 1.43 kB 0 B
./bundle/gemini.js 5.38 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/https-proxy-agent-AVGR4LHR.js 490 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/src-XZYPU6PJ.js 352 kB 0 B
./bundle/start-SCZTCSCE.js 0 B -622 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/worker/worker-entry.js 363 kB 0 B
./bundle/cleanup-LUM4N3AS.js 902 B +902 B (new file) 🆕
./bundle/start-45HIEHZY.js 622 B +622 B (new file) 🆕

compressed-size-action

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes the Gemini CLI's integration with Vertex AI by introducing smarter default endpoint routing and more helpful, context-aware error messages. By targeting official Representative Endpoints based on the user's location, the client avoids legacy hostname issues. Additionally, the update provides clearer feedback when a model is missing in a specific region, guiding users to official documentation to resolve availability issues.

Highlights

  • Vertex AI Endpoint Routing: Implemented automatic routing to official Representative Endpoints (REP) for US and EU multi-regions when using Vertex AI, ensuring more reliable connectivity.
  • Enhanced Error Messaging: Improved ModelNotFoundError handling to provide region-specific guidance and documentation links when models are unavailable in the configured Vertex AI location.
  • Testing Improvements: Added comprehensive unit tests for endpoint selection and error handling, while improving environmental isolation in the test suite.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces support for Vertex AI Representative Endpoints (REP) in the US and EU regions when no base URL is provided, and improves error handling for ModelNotFoundError by displaying region-specific availability messages and documentation links. The review feedback suggests making the GOOGLE_CLOUD_LOCATION environment variable checks more robust by trimming and lowercasing the values to handle case-sensitivity and whitespace-only strings correctly.

Comment thread packages/core/src/core/contentGenerator.ts
Comment thread packages/cli/src/ui/hooks/useQuotaAndFallback.ts
@github-actions github-actions Bot added the size/m A medium sized PR label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 204
  • Additions: +203
  • Deletions: -1
  • Files changed: 4

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Jun 25, 2026
@DavidAPierce DavidAPierce enabled auto-merge June 25, 2026 20:26
@DavidAPierce DavidAPierce added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit b144164 Jun 25, 2026
33 checks passed
@DavidAPierce DavidAPierce deleted the vertex_baseUrl_update branch June 25, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants