What: Provider.Serves now reads a new catalog.LiveAll (the fetched list
with image and video models kept) instead of live(), which drops Draws and
Films models. The draw key loop and the custom video path move on to the
next key when a key answers 404 whose body says the model isn't served
(keyLacksModel = 404 + modelRefused's wording); any other 404 still stops.
Why: wangru8080's analysis on #1657. A relay whose per-key lists name
gpt-image-2 under one key only still had drawing try a key that lacks it:
Serves read a list with the image model filtered out, so every key looked
unlisted, and that key's 404 "Model ... is not supported by any configured
account in this group" ended the loop instead of asking the next key.
Embeddings already move on any error short of the last key.
Run (sandbox HOME, private GOCACHE, worktree at origin/main 97dfed0f3):
- TestDrawGoesPastAKeyTheRelayListsForText, TestCustomVideoGoesPastAKeyThatLacksTheModel.
Break checks: old Serves -> subtest 1 asks key-a first; draw loop without
keyLacksModel -> subtest 2 gets the 404; video loop off -> 404 on start.
A bare 404 still never reaches key-b.
- gofmt -l; go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows;
go build for all three.
- go test -tags nogui ./internal/gateway ./internal/provider
./internal/catalog ./internal/codexcat: all ok.
Not tried against a real relay.
Co-authored-by: wangru8080 <22983744+wangru8080@users.noreply.github.com>
A provider of several keys, each set to serve some models (#474), had
images/generations sent on its first key whatever the key's list said:
drawOnAccounts went over a subscription's accounts but took a key
provider's first key (or the first the calling gateway key may use).
Embeddings and rerank sent a model of one provider on its first key too,
and a video at a provider's own OpenAI-shaped videos API started on it.
A relay that issues one key per model then refused the request.
- draw.go: a key provider now goes through the same candidates and
perKeyBarred as accounts, so a key whose list leaves the model out never
draws, one the vendor lists for another goes last, and with every key
set not to serve the model the caller gets the 403 barredError a chat
gets. Accounts and keys are told apart by AccountID in the left-over
dedupe (accountOf is "" for every key).
- key_models.go: onKeys, the keys or accounts a non-chat request of one
provider goes over, in routing order, barred and calling-key-held ones
out, with the status and message when none is left.
- embeddings.go: a model of one provider goes over onKeys; a group's
members were already planned per key.
- video.go: a custom videomaker starts on onKeys' first key; its id
already carries the key mark, so polling follows it. Grok, Volcengine
and remote videos keep the first allowed key, since their polls are
asked on it again.
- count_tokens already used s.candidates; there is no audio endpoint.
Run: new TestNonChatGoesToTheKeyThatServesIt (draw + embeddings, key-a
text only, key-b image/embedding only; asserts the upstream saw key-b
alone and a 403 with nothing sent when no key serves it) and
TestCustomVideoGoesToTheKeyThatServesIt. Each was broken by hand:
reverting draw.go, embeddings.go or video.go's hunk turns its check red
("drawn on [key-a]", "embedded on [key-a]", "POST /v1/videos kA").
go test -tags nogui ./internal/gateway/ (full package), gofmt -l, and
GOOS=linux/windows go vet -tags nogui ./internal/gateway/.
Not tried against a real relay with per-key model lists.