Skip to content

feat(provider): add Google Vertex AI provider - #10891

Open
lolisaigao1234 wants to merge 9 commits into
AstrBotDevs:masterfrom
lolisaigao1234:main
Open

lolisaigao1234 wants to merge 9 commits into
AstrBotDevs:masterfrom
lolisaigao1234:main

Conversation

@lolisaigao1234

@lolisaigao1234 lolisaigao1234 commented Oct 31, 2026 •

Copy link
Copy Markdown

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 countTokens method. 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 API

Closes #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 d39ad6dd after round four.

Delegate Round 1 · 60fbd9ea Round 2 · 9b660442 Round 3 · d2528e1b Round 4 · a9498f9c
Gemini 4 Neon 7/10 9/10 8.5/10 9.5/10
Claude Opus 5.5 7.5/10 8/10 9/10 9/10
GPT 6.2 Astra 8/10 9/10 10/10 10/10

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>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 9b66044

#7653 [Bug/Feature] 支持Google Vertex AI的API接入 · 1 of 1 met

# Requirement Status Notes
1 新增 Vertex AI 模型供应商预设以接入 Google Vertex AI ✅ Met 新增 Google Vertex AI 模板并启用 SDK 的 Vertex 模式;模型 ID 可从来源配置中提供,旧来源也会从关联模型配置中补充。

#7781 [Feature]新增 Google Vertex Ai 模型供应商预设 · 1 of 1 met

# Requirement Status Notes
1 新增 Google Vertex AI 模型供应商预设 ✅ Met 新增的预设复用 Gemini 适配器,并由 Google Gen AI SDK 使用 Vertex AI 路由。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New gaps against the linked issues

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New gaps against the linked issues

Comment on lines +1350 to +1353
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()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Feature]新增 Google Vertex Ai 模型供应商预设 [Bug/Feature] 支持Google Vertex AI的API接入

1 participant