Skip to content

[STALE: REBASE FROM NEW FORK] feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) - #19

Draft
vadymhimself wants to merge 1 commit into
release/2.65.0-vadymhimself.15from
core-be-r4b/xai-apikey-2278
Draft

vadymhimself wants to merge 1 commit into
release/2.65.0-vadymhimself.15from
core-be-r4b/xai-apikey-2278

Conversation

@vadymhimself

Copy link
Copy Markdown
Collaborator

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.

  • xai-apikey provider. A new key provider for https://api.x.ai/v1, next to openai-apikey and anthropic-apikey, with the xai sign-in row's lineup and wire metadata and no default model. Writing a company key onto the xai row itself would replace the Grok sign-ins through allowKeyAuthOverride, so the key gets its own row.
  • Keys never take the sign-ins' traffic. activeProviderEntries now lists every signed-in provider before any -apikey provider, and routeByKnownModelPattern goes through it. Before this, a key written before the first sign-in came first in the config, so a bare claude-* or grok-* 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:

  • control: a key alone still serves bare ids;
  • no-hijack row: with keys written before the sign-ins, every bare id lands on the sign-in, and the key is reached only by its namespace;
  • namespace: xai-apikey/<model> routes to the key with key auth.

tests/providers/provider-registry-parity.test.ts lists xai-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 base release/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 .21 and the provisioner deploy are applied by the lead (infra). The paperclip half is a separate PR into dev; both are reviewed by qa-sec-8u.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 13, 2026
@github-actions github-actions Bot changed the title feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) [WRONG BRANCH] feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) Nov 13, 2026
@github-actions

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (release/2.65.0-vadymhimself.15); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request is being kept as a draft automatically. Once every issue above is resolved, it will be marked ready for review again.

@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 01:08
@vadymhimself vadymhimself changed the title [WRONG BRANCH] feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) [STALE: REBASE FROM NEW FORK] feat(providers): xAI by API key as its own provider; keys never take the sign-ins' traffic (.21) Nov 18, 2026
@vadymhimself

Copy link
Copy Markdown
Collaborator Author

This PR is based on the superseded 2.65 gateway line. Rebuild the change from port/ar-on-upstream-2026-11-18 (upstream-derived 2.100 AR overlay, PR #46): #46 . Do not rebase onto or merge the old release line. Preserve the new gateway quota/cache gate and re-run the affected regressions. The candidate is not deployed; do not publish or replace a running gateway without explicit approval.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant