Skip to content

feat(provider): support per-provider Google credentials for Vertex AI#19931

Closed
major wants to merge 1 commit into
anomalyco:devfrom
major:feat/vertex-ai-per-provider-credentials
Closed

feat(provider): support per-provider Google credentials for Vertex AI#19931
major wants to merge 1 commit into
anomalyco:devfrom
major:feat/vertex-ai-per-provider-credentials

Conversation

@major
Copy link
Copy Markdown
Contributor

@major major commented Mar 29, 2026

Issue for this PR

Closes #19930

Type of change

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

What does this PR do?

Passes googleAuthOptions from provider config through to the AI SDK for both
google-vertex and google-vertex-anthropic, so each provider can authenticate
with separate GCP credentials.

Changes to google-vertex loader:

  • Extracts googleAuthOptions from config and spreads it into SDK options
  • Passes it to new GoogleAuth(...) in the custom fetch for openai-compatible models
  • Switches from getApplicationDefault() to getClient() (backward-compatible,
    falls back to ADC when no explicit credentials given)

Changes to google-vertex-anthropic loader:

  • Fixes a bug where the function signature was async () =>, silently ignoring
    all config options (project, location, etc.)
  • Now checks config options before env vars for project and location,
    matching the google-vertex pattern
  • Passes googleAuthOptions through to SDK options

Both changes are backward-compatible. When googleAuthOptions is absent, behavior
is identical to before.

How did you verify your code works?

  • bun typecheck passes (exit 0)
  • bun test test/provider/provider.test.ts passes (73 pass, 0 fail) including
    3 new tests:
    • google-vertex-anthropic: respects config-level project and location
    • google-vertex: passes googleAuthOptions to provider options
    • google-vertex-anthropic: passes googleAuthOptions to provider options

Screenshots / recordings

N/A - no UI changes.

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found related PRs that address similar authentication topics for Google Vertex AI:

Potentially Related PRs:

  1. feat: add Google Vertex AI service account JSON authentication #6287 - "feat: add Google Vertex AI service account JSON authentication"

    • Related to Google Vertex AI authentication methods
  2. fix(opencode): pass OAuth scopes to GoogleAuth for Vertex AI #15110 - "fix(opencode): pass OAuth scopes to GoogleAuth for Vertex AI"

    • Also involves GoogleAuth configuration for Vertex AI
  3. feat: support bearer token auth for google-vertex-anthropic #14177 - "feat: support bearer token auth for google-vertex-anthropic"

    • Addresses authentication for google-vertex-anthropic provider

These PRs touch on similar authentication concerns for Google Vertex AI providers, though they may have been merged or closed previously. However, PR #19931 is the current PR you're checking, and it appears to be the first to specifically address per-provider Google credentials with googleAuthOptions support for both providers simultaneously.

@rekram1-node
Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

[FEATURE]: Support per-provider Google credentials for Vertex AI

2 participants