Fix xAI OAuth subscription transport routing - #113
Merged
lidge-jun merged 1 commit intoJul 12, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
xaiprovider through the Grok CLI subscription endpoint only whenauthModeisoauth.api.x.aitransport for API-key authentication.Why
The xAI preset accepts both OAuth and API-key credentials, but both modes currently share
https://api.x.ai/v1. A valid Grok subscription OAuth token is therefore evaluated against API-team spend limits and can receive HTTP 429 with an RPM limit of0/0, even while subscription quota is available.The same OAuth token succeeds against
https://cli-chat-proxy.grok.com/v1with the Grok CLI client markers. This change keeps the persisted preset compatible with the dashboard's "Use an API key instead" switch and resolves the effective transport at request time, so the two billing surfaces cannot silently cross.Closes #112.
Verification
bun run typecheckbun test tests/xai-transport.test.ts tests/provider-live-models.test.ts tests/provider-quota.test.ts tests/openai-chat-hardening.test.ts— 20 passedbun run testbun run privacy:scanbun run build:guinpm pack --dry-runxai/grok-4.5structured-output smoke: upstream HTTP 200, reported usage, zero retry/correction, canonical output valid, VM advanced successfully.Checklist
oauth / key, so no user-facing text change is required.