github / github/app

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

Offen
#3,269 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Keine Sprachdaten
Sterne
2.1k
Forks
153
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne unter Settings → Custom model provider und reproduziere die Anfrage gegen den im Issue angegebenen Gemini-kompatiblen Endpunkt. Verfolge, wie der konfigurierte API-Schlüssel für das Google-Gemini-Format angewendet wird, und überprüfe anschließend, dass die abgeschlossene Anfrage den erforderlichen Authorization: Bearer-Header enthält und erfolgreich gegen den Proxy ausgeführt wird, ohne das bestehende Gemini-Anfrageverhalten zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Bereich
api, authentication
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.