Repository navigation
feat(provider): add Google Vertex AI provider - #10891
lolisaigao1234 wants to merge 9 commits into
Conversation
Add a "Google Vertex AI" provider source that reuses the existing googlegenai_chat_completion adapter with the google-genai SDK's Vertex mode, so all Gemini features (thinking, native search, code execution, URL context, safety settings, image output) work on Vertex AI. Authentication: an API key (express mode, or a key bound to a service account together with a project ID), a service account key file, or Application Default Credentials. Closes AstrBotDevs#7781 Closes AstrBotDevs#7653 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#7653 [Bug/Feature] 支持Google Vertex AI的API接入 · 1 of 2 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add a dedicated Google Vertex AI provider preset that uses Vertex AI routing. | ✅ Met | The new preset enables Vertex mode in the existing Gemini adapter, which lets the SDK select the Vertex endpoint. |
| 2 | Get a model list and call models through Vertex AI. | 🟡 Partly met | Vertex requests can be made, but model listing remains unavailable with API-key authentication; users must add a model ID manually. |
#7781 [Feature]新增 Google Vertex Ai 模型供应商预设 · 1 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add a Google Vertex AI model provider preset. | ✅ Met | The preset, its Vertex configuration fields, and provider-picker entry are added. |
Sourcery assessment
Needs a human reviewer. The provider now authenticates Vertex AI requests with an API key, service-account credentials, or ADC, so a credential or project-resolution mistake could send prompts under an unintended cloud identity and incur usage. Reverting stops future requests but cannot undo data already sent or charges already incurred.
Linked issuesChecked at commit 9b66044 #7653 [Bug/Feature] 支持Google Vertex AI的API接入 · 1 of 1 met
#7781 [Feature]新增 Google Vertex Ai 模型供应商预设 · 1 of 1 met
|
| if self.vertexai: | ||
| # Model Garden lists publisher models regardless of project prediction access. | ||
| model_ids = self.provider_config.get("gm_vertex_models", []) | ||
| return list(dict.fromkeys(m.strip() for m in model_ids if m.strip())) |
There was a problem hiding this comment.
🟡 Medium · Remote model discovery absent
The issue reports that users cannot obtain a model list as well as call models. The Vertex branch returns only configured model IDs, so a new source with the default empty list does not discover available models.
Prompt for AI agents
In `astrbot/core/provider/sources/gemini_source.py` at lines 1350-1353:
**Remote model discovery absent**
The issue reports that users cannot obtain a model list as well as call models. The Vertex branch returns only configured model IDs, so a new source with the default empty list does not discover available models.From #7653:
Allow users to obtain a model list and call Vertex AI models.
Summary
Add a Google Vertex AI preset to the existing Gemini chat adapter. The Google Gen AI SDK selects the endpoint and API version for express keys, project-bound keys and Application Default Credentials. Project-bound keys require google-genai 2.15.0 or newer. The global dependency floor stays at 1.56.0 for WebUI upgrade compatibility.
Fetch Models takes Gemini candidates from the Vertex section of AstrBot's existing model metadata feed. It checks candidates with the source's own client, project and location using Google's free
countTokensmethod. Image-output sources check image models. Only successful probes appear. Test Model verifies generation, and Custom Model supports IDs absent from the feed. Google Count Tokens APICloses #7653
Closes #7781
Verification
On the deployed revision, the authenticated dashboard endpoint returned 12 chat models and 5 image models, with only one model saved for each source before discovery. The chat results included Gemini 4 Carbon, Hydrogen, Argon and Neon.
The configured Vertex key successfully counted a token on previously unsaved Gemini 4 Carbon, Hydrogen and Argon. Vertex returned HTTP 404 for Gemini 3.6 Flash and for a nonexistent model ID. The focused Gemini and provider user-agent suites passed 73 tests with one skip.
Council review
The four rounds below reviewed earlier revisions. Free discovery was added in
d39ad6ddafter round four.60fbd9ea9b660442d2528e1ba9498f9c