github / github/app

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

Aperta
#3,269 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
2.1k
Fork
153
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start at Settings → Custom model provider and reproduce the request against the Gemini-compatible endpoint shown in the issue. Trace how the configured API key is applied for the Google Gemini format, then verify that the completed request includes the required Authorization: Bearer header and succeeds against the proxy without breaking the existing Gemini request behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
api, authentication
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
58/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.