Files
ai-kit/test
CatoandClaude Opus 5.5 13c8e8c0cb feat(byok): "does this key work, and what can it use?" — probeByokKey (1.17.0) (#76)
The moment a reader pastes a key, a settings screen needs two answers: does
it work, and which models can it reach — so it can preselect the best one
instead of showing a text box and failing in the chat later. OrangeCat
answered the first and threw the second away; Loki had neither.

probeByokKey checks a key the way each vendor checks keys, verified against
the live endpoints on 2026-09-25:
- OpenRouter's /models is a public catalogue that answers 200 to a FAKE key,
  so its key is checked at /key.
- Anthropic's model list wants x-api-key plus a version header.
- Google and xAI reject a bad key with 400, not 401 — any non-2xx fails,
  in the vendor's own words, with the key masked if the vendor echoes it.
- An unreachable vendor is "couldn't check", never "your key is wrong".

The suggestion names no model (the newest ids that day were
claude-opus-5.5, gpt-6-luna-pro, grok-4.7 — none of which this package had
seen). It is the newest model in the strongest tier the key can use: tier
from the name, age from the vendor's dates or, where there are none
(Google), from the version in the name, with a vendor's -latest alias as
newest; speed variants never on top; a router's frontier-lab namespaces
first. Run live against real Groq, Gemini and OpenRouter keys it suggests
gpt-oss-120b, gemini-pro-latest and anthropic/claude-opus-5.5.

readCatalog is the one GET behind fetchCatalog, keeping the status and the
vendor's message that fetchCatalog deliberately collapses; ModelRecord gains
`created`. Additive: no existing export changes behaviour.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 07:32:17 -07:00
..