feat: Vertex AI provider - #48
Open
amal66 wants to merge 1 commit into
Open
Conversation
Route Gemini model IDs through Google Cloud Vertex AI instead of the AI Studio endpoint. setupVertexAI() re-registers the "gemini" provider id in the provider registry with a Vertex AI-backed adapter that authenticates via Application Default Credentials (no API key). Model IDs are unchanged, so routing is transparent to all call sites. Nothing changes unless setupVertexAI() is called at startup. Mechanical port of apps/api/src/lib/llm/providers/vertexAI.ts and its test from amal66/mike@main (commit b3166dd), verbatim; stacks on the provider-registry branch it registers into. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Google models via Vertex AI without touching call sites:
setupVertexAI()swaps the built-in Gemini provider for one that routes the same Gemini model IDs through Google Cloud Vertex AI — enterprise billing, IAM-gated access, and Workload Identity instead of a distributed API key.Changes
backend/src/lib/llm/providers/vertexAI.ts— Vertex AI provider: streams and completes via@google/genaiwithvertexai: true(Application Default Credentials,VERTEX_AI_PROJECT/VERTEX_AI_LOCATION), supports tool calls, thinking deltas, and abort;setupVertexAI()re-registers the"gemini"provider id in the registry, so every existing Gemini model ID transparently routes to Vertex AI.backend/src/lib/llm/__tests__/vertexAI.test.ts— 7 tests covering registration, model matching, extra models, and re-registration.Why
AI Studio API keys are unsuitable for enterprise deployments that need project-scoped billing, VPC-SC/data-residency compliance, or keyless Workload Identity. No new dependencies:
@google/genai@^1.50.1is already inbackend/package.json. Zero behavior change unless configured — nothing callssetupVertexAI()by default, and the provider throws a clear error ifVERTEX_AI_PROJECTis unset.Base is
upstream-pr/provider-registry(stacked PR): the provider registers itself viaregisterProvider()fromlib/llm/registry.ts, which only exists on that branch — it cannot stand alone onupstream-main.Testing
npm install && npm run build(tsc) green on the branch as committed, from a cleannode_modules.upstream-pr/test-harness) merged locally:npm test→ 4 files, 39 tests passed (7 vertexAI from this branch; 10 registry + 10 models from the base branch; 12 pre-existing downloadTokens).Provenance
All changes are mechanical ports of amal66/mike@origin/main (commit b3166dd):
apps/api/src/lib/llm/providers/vertexAI.tsandapps/api/src/lib/llm/__tests__/vertexAI.test.ts, both byte-identical to the fork's files — the imports (../types,../tools,../registry,../models) all resolve on the provider-registry base. Exceptions: none.🤖 Generated with Claude Code
https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC