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
gemini provider (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.go implementing provider.Provider. The official genai/Vertex Go SDK exposes Gemini-on-Vertex; the existing backend/pkg/providers/gemini/gemini.go is the closest reference and the request-shaping logic may be largely reusable behind a Vertex transport/auth layer.
- Constants — add
ProviderVertex ProviderType = "vertex" and DefaultProviderNameVertex in backend/pkg/providers/provider/provider.go.
- Registration — wire into
DefaultProviderConfig, NewProvider, buildProviderFromConfig, GetProvider in backend/pkg/providers/providers.go.
- REST validation — add
vertex to the Valid() whitelist in backend/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_ID
VERTEX_LOCATION (e.g. us-central1)
VERTEX_CREDENTIALS_FILE (path to service-account JSON; fall back to ADC / GOOGLE_APPLICATION_CREDENTIALS when empty)
- optionally
VERTEX_SERVER_URL for regional/private endpoints
- Migration — goose migration in
backend/migrations/sql/ adding 'vertex' to the PROVIDER_TYPE enum, following the enum-swap pattern in 20260227_120000_add_cn_providers.sql (Up: recreate enum incl. vertex; Down: delete vertex rows then recreate without it).
- Frontend — provider icon
frontend/src/components/icons/vertex.tsx registered in provider-icon.tsx, plus settings-page wiring.
- Docs/
.env.example — document the new keys.
Open questions for maintainers
- Adapter strategy — extend/parameterize the existing
gemini adapter to support a Vertex transport+auth mode, or a fully separate vertex package? (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
anthropic adapter 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
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
customprovider — functional but requires running extra infrastructure.Goals
Non-goals
geminiprovider (kept as-is).Proposed implementation
Follows the repo's documented "Adding a New LLM Provider" checklist (CLAUDE.md). Concrete touch points verified against
main: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.ProviderVertex ProviderType = "vertex"andDefaultProviderNameVertexinbackend/pkg/providers/provider/provider.go.DefaultProviderConfig,NewProvider,buildProviderFromConfig,GetProviderinbackend/pkg/providers/providers.go.vertexto theValid()whitelist inbackend/pkg/server/models/providers.go(without this the REST API returns 422).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)VERTEX_SERVER_URLfor regional/private endpointsbackend/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/src/components/icons/vertex.tsxregistered inprovider-icon.tsx, plus settings-page wiring..env.example— document the new keys.Open questions for maintainers
geminiadapter to support a Vertex transport+auth mode, or a fully separatevertexpackage? (Affects code reuse vs. clean separation.)anthropicadapter with a Vertex auth/endpoint mode instead.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