[Enhancement]: Native Google Vertex AI provider (service-account auth)
Summary
Add a native Google Vertex AI provider (vertex) so users can authenticate with GCP project credentials instead of an API key. Today the only Google option, gemini (GEMINI_SERVER_URL=https://generativelanguage.googleapis.com), targets AI Studio and does not accept Vertex project/service-account credentials. Anthropic Claude-on-Vertex is likewise unsupported.
Motivated by #310, where a user could not configure Vertex AI keys. The current workaround is to front Vertex with a LiteLLM proxy and use the custom provider — functional but requires running extra infrastructure.
Goals
- Authenticate via GCP Application Default Credentials / a service-account JSON key, with explicit project ID and region/location.
- Support Gemini models on Vertex; ideally also Claude-on-Vertex (Anthropic models served through Vertex).
Non-goals
- Replacing the existing AI Studio
geminiprovider (kept as-is). - Per-request dynamic credentials / multi-project routing (future work).
Proposed implementation
Follows the repo's documented "Adding a New LLM Provider" checklist (CLAUDE.md). Concrete touch points verified against main:
- Provider impl —
backend/pkg/providers/vertex/vertex.goimplementingprovider.Provider. The officialgenai/Vertex Go SDK exposes Gemini-on-Vertex; the existingbackend/pkg/providers/gemini/gemini.gois the closest reference and the request-shaping logic may be largely reusable behind a Vertex transport/auth layer. - Constants — add
ProviderVertex ProviderType = "vertex"andDefaultProviderNameVertexinbackend/pkg/providers/provider/provider.go. - Registration — wire into
DefaultProviderConfig,NewProvider,buildProviderFromConfig,GetProviderinbackend/pkg/providers/providers.go. - REST validation — add
vertexto theValid()whitelist inbackend/pkg/server/models/providers.go(without this the REST API returns 422). - Config — add env keys in
backend/pkg/config/config.go, e.g.:VERTEX_PROJECT_IDVERTEX_LOCATION(e.g.us-central1)VERTEX_CREDENTIALS_FILE(path to service-account JSON; fall back to ADC /GOOGLE_APPLICATION_CREDENTIALSwhen empty)- optionally
VERTEX_SERVER_URLfor regional/private endpoints
- Migration — goose migration in
backend/migrations/sql/adding'vertex'to thePROVIDER_TYPEenum, following the enum-swap pattern in20260227_120000_add_cn_providers.sql(Up: recreate enum incl.vertex; Down: deletevertexrows then recreate without it). - Frontend — provider icon
frontend/src/components/icons/vertex.tsxregistered inprovider-icon.tsx, plus settings-page wiring. - Docs/
.env.example— document the new keys.
Open questions for maintainers
- Adapter strategy — extend/parameterize the existing
geminiadapter to support a Vertex transport+auth mode, or a fully separatevertexpackage? (Affects code reuse vs. clean separation.) - Scope — Gemini-on-Vertex only first, or include Claude-on-Vertex in the same provider? Claude-on-Vertex uses the Anthropic message schema, which may argue for routing it through the
anthropicadapter with a Vertex auth/endpoint mode instead. - Auth surface — is service-account JSON file + ADC sufficient, or is workload-identity / bearer-token (mirroring the Bedrock multi-auth approach) also desired?
- Web settings — should Vertex be configurable from the Settings UI like other providers, or env-only initially given the credential-file requirement?
I'm happy to implement this once direction on Q1–Q2 is confirmed. Note the DB migration + GCP auth flow are areas that will need maintainer review and GCP credentials to test end-to-end.
References
- #310 (original Vertex AI request)
- CLAUDE.md → "Adding a New LLM Provider"
- LiteLLM Vertex docs: https://docs.litellm.ai/docs/providers/vertex
Not planned: reachable through the gateway; a dedicated door has no consumer. Closing — comment here if that changes.