Skip to content

feat: Vertex AI provider - #48

Open
amal66 wants to merge 1 commit into
upstream-pr/provider-registryfrom
upstream-pr/vertex-ai
Open

feat: Vertex AI provider#48
amal66 wants to merge 1 commit into
upstream-pr/provider-registryfrom
upstream-pr/vertex-ai

Conversation

@amal66

@amal66 amal66 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

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/genai with vertexai: 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.1 is already in backend/package.json. Zero behavior change unless configured — nothing calls setupVertexAI() by default, and the provider throws a clear error if VERTEX_AI_PROJECT is unset.

Base is upstream-pr/provider-registry (stacked PR): the provider registers itself via registerProvider() from lib/llm/registry.ts, which only exists on that branch — it cannot stand alone on upstream-main.

Testing

  • npm install && npm run build (tsc) green on the branch as committed, from a clean node_modules.
  • With the vitest harness (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.ts and apps/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

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

1 participant