Skip to content

fix(models): recognize google-generative-ai as google-gemini api type#241

Merged
1186258278 merged 1 commit intoqingchencloud:mainfrom
friendfish:fix/google-gemini-auth
Apr 24, 2026
Merged

fix(models): recognize google-generative-ai as google-gemini api type#241
1186258278 merged 1 commit intoqingchencloud:mainfrom
friendfish:fix/google-gemini-auth

Conversation

@friendfish
Copy link
Copy Markdown
Contributor

问题

关联 Issue:#239

前端 PROVIDER_PRESETS 中,Google 供应商的 api 字段被定义为 "google-generative-ai",而后端 normalize_model_api_type() 函数只识别 "google-gemini"

这导致 google-generative-ai 类型被 fallthrough 到默认的 "openai-completions",进而使 list_remote_models()test_model()probe_model() 等函数都错误地发送 Authorization: Bearer 请求头,而非 Google Generative Language API 要求的 ?key= 查询参数,最终返回 401 Unauthorized

修复

normalize_model_api_type() 的 match arm 中,将 "google-generative-ai" 作为 "google-gemini" 的别名加入:

// Before
"google-gemini" => "google-gemini",

// After
"google-gemini" | "google-generative-ai" => "google-gemini",

影响范围

  • 影响文件:src-tauri/src/commands/config.rs,仅修改 1 行
  • 不影响任何现有逻辑;已使用 "google-gemini" 的配置行为不变
  • 修复后,前端以 api: "google-generative-ai" 配置 Google 供应商时,获取模型列表、测试连接均可正常工作

The frontend PROVIDER_PRESETS defines Google's api field as
'google-generative-ai', but normalize_model_api_type() only recognized
'google-gemini'. This caused the type to fall through to 'openai-completions',
making list_remote_models(), test_model(), and probe_model() all send
an 'Authorization: Bearer' header instead of the correct '?key=' query
param — resulting in 401 Unauthorized from Google's Generative Language API.

Fix: add 'google-generative-ai' as an alias for 'google-gemini' in the
normalize_model_api_type() match arm.

Fixes qingchencloud#239
@1186258278 1186258278 merged commit 66e57ad into qingchencloud:main Apr 24, 2026
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.

2 participants