Repository navigation
[STALE: REBASE FROM NEW FORK] feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) - #19
Conversation
…the sign-ins' traffic (.21) AgentRadar AGE-2278 lets a company add an API key for Claude, Codex or Grok and run it in its model waterfall next to the subscription sign-ins. The gateway needs two things for that. xai-apikey is a new key provider for https://api.x.ai/v1, placed next to the OpenAI and Anthropic key rows. It carries the same lineup and wire metadata as the xai sign-in row, but no default model. A company key written onto the xai row itself would replace the Grok sign-ins through allowKeyAuthOverride, so the key gets its own row. Bare model ids now reach a signed-in provider before its -apikey twin, whatever order the config was written in. Before this, a key added before the first sign-in sat earlier in the config, and routeByKnownModelPattern, the configured-default-model step and the model-list step all took the first match, so a bare claude-* or grok-* request went to the key. Pinned AgentRadar requests already refused a key route; unpinned ones could have spent the key. A key is now reached only through its own namespace (anthropic-apikey/..., xai-apikey/...). Tests: tests/routing/router.test.ts adds a control (a key alone serves bare ids) and the no-hijack row (keys written first, every bare id still lands on the sign-ins, the key only by its namespace). The parity list gains xai-apikey. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
|
This PR is based on the superseded 2.65 gateway line. Rebuild the change from |
|
Trial evidence: before the merge the build ran 30.5 h on the laptop gateway and 24 h on the personal Mac Mini gateway, both with For new work:
Before opening a PR, use pinned Bun 1.4.4 with an isolated
Hosted-only behavior needs For this PR: carried as the separate 🤖 Generated with Claude Code |
What
AgentRadar AGE-2278 (ruling 21404) lets a company add an API key for Claude, Codex or Grok and place it in its model order beside the subscription sign-ins. The gateway image needs two changes for that.
https://api.x.ai/v1, next toopenai-apikeyandanthropic-apikey, with the xai sign-in row's lineup and wire metadata and no default model. Writing a company key onto thexairow itself would replace the Grok sign-ins throughallowKeyAuthOverride, so the key gets its own row.activeProviderEntriesnow lists every signed-in provider before any-apikeyprovider, androuteByKnownModelPatterngoes through it. Before this, a key written before the first sign-in came first in the config, so a bareclaude-*orgrok-*id went to the key. A key is now reached only through its own namespace (anthropic-apikey/...,openai-apikey/...,xai-apikey/...). AgentRadar's pinned requests already refused a key route; this closes the unpinned path.Version bumped to
.21.Tests
tests/routing/router.test.ts, AGE-2278 block:xai-apikey/<model>routes to the key with key auth.tests/providers/provider-registry-parity.test.tslistsxai-apikey.Lane run (
bun scripts/test.ts ./tests/providers ./tests/routing ./tests/lab ./tests/usage ./tests/oauth): 8031 pass, 6 fail. The same 6 fail on the baserelease/2.65.0-vadymhimself.15(grok-config-inject x3, grok-orphan-adoption, usage-summary custom windows, oauth-callback-server socket pin), so none is from this change.Eval added/updated: N/A deterministic (unit: tests/routing/router.test.ts)
Release
Tag
.21and the provisioner deploy are applied by the lead (infra). The paperclip half is a separate PR intodev; both are reviewed by qa-sec-8u.🤖 Generated with Claude Code