Skip to content

fix: add GOOGLE_VERTEX_LOCATION env var support for Vertex AI#16922

Open
SOUMITRO-SAHA wants to merge 3 commits intoanomalyco:devfrom
SOUMITRO-SAHA:fix/google-vertex-location-env
Open

fix: add GOOGLE_VERTEX_LOCATION env var support for Vertex AI#16922
SOUMITRO-SAHA wants to merge 3 commits intoanomalyco:devfrom
SOUMITRO-SAHA:fix/google-vertex-location-env

Conversation

@SOUMITRO-SAHA
Copy link

The @ai-sdk/google-vertex package expects GOOGLE_VERTEX_LOCATION as the standard environment variable for location. Added this env var to the fallback chain in both googleVertexVars() and CUSTOM_LOADERS.

Fixes #15838

Issue for this PR

Closes #15838

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Problem: When using Google Vertex AI models (e.g., gemini-3.1-pro-preview), users get an AI_LoadSettingError even after setting the GOOGLE_VERTEX_LOCATION environment variable.

Root Cause: The code in packages/opencode/src/provider/provider.ts was only checking GOOGLE_CLOUD_LOCATION and VERTEX_LOCATION environment variables, but the @ai-sdk/google-vertex package expects GOOGLE_VERTEX_LOCATION as the standard environment variable name (confirmed by reading the package's TypeScript definitions and source code in node_modules).

Fix: Added GOOGLE_VERTEX_LOCATION to the environment variable fallback chain in two locations:

  1. googleVertexVars() function (line ~69)
  2. CUSTOM_LOADERS["google-vertex"] async function (line ~395)

Why it works: The @ai-sdk/google-vertex package uses loadSetting() with environmentVariableName: "GOOGLE_VERTEX_LOCATION". By checking this environment variable in opencode's provider initialization, the value is now properly passed through to the underlying SDK.

How did you verify your code works?

  1. Read the @ai-sdk/google-vertex package source code in node_modules to confirm the expected environment variable
  2. Ran existing provider tests: bun test test/provider/provider.test.ts - 70 tests passed
  3. Ran transform tests: bun test test/provider/transform.test.ts - 107 tests passed
  4. Verified the fix with git diff showing the minimal change

Screenshots / recordings

N/A - backend fix

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

SOUMITRO-SAHA and others added 3 commits March 10, 2026 23:51
The @ai-sdk/google-vertex package expects GOOGLE_VERTEX_LOCATION as the
standard environment variable for location. Added this env var to the
fallback chain in both googleVertexVars() and CUSTOM_LOADERS.

Fixes anomalyco#15838
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.

AI_LoadSettingError: Google Vertex location setting is missing when using Gemini models

2 participants