github / github/app

Custom model provider: support Bearer token auth for Google Gemini-compatible endpoints

Đang mở
#3,269 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
2.1k
Fork
153
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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 |

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu từ Settings → Custom model provider và tái hiện request tới endpoint tương thích với Gemini được hiển thị trong issue. Theo dõi cách API key đã cấu hình được áp dụng cho định dạng Google Gemini, sau đó xác minh rằng request hoàn chỉnh có header Authorization: Bearer bắt buộc và thành công khi gửi tới proxy mà không làm hỏng hành vi request Gemini hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Lĩnh vực
api, authentication
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.