fix(grok): align OAuth requests with official CLI proxy#4037
Open
superman2003 wants to merge 4 commits into
Open
fix(grok): align OAuth requests with official CLI proxy#4037superman2003 wants to merge 4 commits into
superman2003 wants to merge 4 commits into
Conversation
…header # Conflicts: # backend/internal/service/openai_gateway_grok_test.go
FLuoXue
added a commit
to FLuoXue/sub2api
that referenced
this pull request
Jul 12, 2026
…ion header) Pull Grok OAuth subscription routing and CLI version header fixes into local main.
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
https://cli-chat-proxy.grok.com/v1.https://api.x.ai/v1OAuth base URLs at runtime without rewriting stored credentials.grok-4.5.X-Grok-Client-Version: 0.2.93consistently on Grok upstream requests.Root cause
Grok OAuth exports historically store
https://api.x.ai/v1. That is the credit-backed xAI API, so a valid Free subscription account can fail there with HTTP 402personal-team-blocked:spending-limiteven though the same token is entitled to use Grok 4.5 through the official CLI proxy. Free accounts may also reject the oldgrok-4.3probe default.This PR keeps the paid API path for API-key accounts and changes only OAuth subscription defaults and legacy OAuth values.
Related work
The focused OAuth routing commit is carried from #4009 (
06b5e6b8) with the original author preserved. This PR does not include #4009's broader API-key UI or quota-display changes.Verification
All commands above pass locally. The frontend targeted suite reports 2/2 tests passed.
A sanitized live comparison was also run with one user-supplied OAuth export, read-only and without token refresh or credential writes:
/models: HTTP 200 and includesgrok-4.5.api.x.ai/v1/responses: HTTP 402personal-team-blocked:spending-limit./responses: HTTP 200 withresponse.completed./chat/completions: HTTP 200.Residual risk
OAuth media endpoints also use the account's normalized Grok base URL. Chat, Responses, health checks, quota probes, and WebSocket fallback are covered; image/video generation was not live-tested to avoid a potentially billable request. API-key media routing remains unchanged.