corddis_114 on Discord has a relay that gives out a key per protocol,
one of them for Gemini ("gemini sk-d…SarG"), and the key row's protocol
menu offered Any, Anthropic, Chat Completions and Responses only. A
custom provider already serves Gemini upstream (its Gemini URL, the
"Gemini compatible" tab, x-goog-api-key, the model list through
FetchGemini, probes), so only the per-key layer lacked it:
- keyProtocolOK takes "gemini"; WithKey leaves a Gemini key the Gemini
URL only and takes the Gemini URL from a key made for another
protocol (it had kept it, so an Anthropic key could be sent to
generateContent).
- keyFit: a gemini* model (modelFamily Gemini) goes to the key made for
Gemini first, the other keys in their order behind it; a GPT model is
never put on the Gemini key (it ranked 0 there before). Claude's rule
is unchanged.
- app.js: Gemini in PROTO_OPTS ("Gemini API (generateContent) · Gemini
CLI, Gemini models"), offered when the provider has a Gemini URL;
keyLacksURL says "No Gemini URL" for a Gemini key without one. The
note in zh, zh-TW, ja and de. The provider-level tabs and Routing's
"keys for Gemini" already had it.
Run on mote (go1.26.8):
- go test -timeout 45m ./internal/provider ./internal/gateway: both ok (provider 229s, gateway 938s).
- TestKeyMadeForGemini, TestKeyProtocolGemini, TestKeysMadeForOneProtocol,
TestKeyForAProtocolWithNoURLIsSaid, TestKeyPoolsByProtocol,
TestCustomGeminiUpstream ok; internal/gui's budget tests ok.
- GUI (node --test, Chromium and WebKit, en/zh/zh-TW/ja/de, 420 and
1000px): key-gemini (new, 40/40), key-nourl, proto-menu-overflow,
key-row-chips-fit, key-plan, key-import, key-weight-fit,
provider-many-keys, provider-gemini, provider-add-gemini,
provider-url-each-api, model-api-gemini, provider-base-api,
routing-keys-fold and i18n-keys ok; the only red in the 360 was
tencent-cloud's region-strip test (#4321, open).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
go vet on provider, gateway, gui ok.
Broken by hand: the old fallback.go turns TestKeyMadeForGemini red
(Gemini models went to the Chat or Anthropic key, GPT to the Gemini
one); the old keys.go turns TestKeyProtocolGemini red (unknown
protocol "gemini"), and WithKey keeping p.Gemini turns it red too (the
Anthropic key speaks [anthropic gemini]); the old app.js turns
key-gemini red in all 40.
Not tried: the reporter's relay or any real Gemini-compatible relay;
the real app's editor.