Custom model provider: support Bearer token auth for Google Gemini-compatible endpoints
- 主要语言
- 没有语言数据
- 星标
- 2.1k
- 派生
- 153
- PR 合并指标
- 30 天内没有已合并 PR
描述
## Problem
When configuring a custom model provider using the **Google Gemini** format, the Copilot app appears to send the API key as a `?key=` query parameter (Google's standard auth). However, enterprise Gemini-compatible proxies (e.g. SAP Hyperspace LLM Proxy) require the API key to be sent as an `Authorization: Bearer` header — not as a query param.
This makes it impossible to use Gemini-native endpoints from corporate proxies with custom model providers.
## Reproduction
1. Add a custom model provider with base URL pointing to a Gemini-compatible proxy (e.g. `http://localhost:6655/gemini`)
2. Set the API key to the proxy's bearer token
3. Attempt to use the model → fails with auth error on the proxy side (`Missing Authorization header`)
The proxy endpoint works correctly when called with `Authorization: Bearer `:
```
curl -X POST http://localhost:6655/gemini/v1beta/models/gemini-3.5-flash:generateContent \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"hi"}]}]}'
```
## Expected behavior
The custom Gemini model provider should send the API key as `Authorization: Bearer ` (in addition to or instead of `?key=`), to support enterprise proxies that follow this pattern.
## Workaround attempted
Using the OpenAI-compatible endpoint (`/litellm/v1`) works but **prompt caching does not function** through that path (related: #1975).
## Environment
| Field | Value |
|---|---|
| App version | 1.0.80 |
| OS | macOS |
| Path | /settings → Custom model provider |
贡献指南
调研方向
从 Settings → Custom model provider 开始,针对 issue 中显示的 Gemini 兼容端点重现该请求。跟踪已配置的 API key 如何应用于 Google Gemini 格式,然后验证已完成的请求包含所需的 Authorization: Bearer 标头,并且能够在不破坏现有 Gemini 请求行为的情况下通过代理成功执行。
由索引模型根据 Issue 内容生成。
评估
- 领域
- api, authentication
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 58/100