Repository navigation
Description
Client or integration
Direct HTTP/API client
Area
Provider adapter
Summary
On the xAI OAuth lane (grok-oauth), when the xAI account's privacy setting is "Legacy (no storage)", xAI rejects every Grok Build / CLI-proxy call with HTTP 403 and a body that names the exact fix:
{"error":"Grok Build is not supported in Legacy (no storage). Switch to Privacy Mode to use Grok Build. [WKE=privacy-mode:legacy]"}
opencodex currently discards that marker and answers the client with the generic access_denied copy (The provider denied access to this request.), so the user has no way to learn that a single account toggle unblocks them. Expected: a fixed, actionable message that names the setting and the action.
This is not a one-off: while the gate is active, model discovery (/v1/models), the quota probe (/v1/billing?format=credits) and every chat/responses turn fail the same way, and ocx provider test xai only prints upstream model discovery returned 403. A comparable client hit the same silence and filed it as a bug: pingdotgg/t3code#28094 ("Grok usage limits hide xAI's 'Switch to Privacy Mode' 403 behind 'Grok could not read usage limits'").
Reproduction
Account state: xAI OAuth (subscription tier SuperGrokPro), privacy setting Legacy (no storage).
ocx provider test xai
→xai: failed/upstream model discovery returned 403- Send any turn through the gateway:
→
curl -s http://127.0.0.1:10100/v1/chat/completions \ -H "Authorization: Bearer $OCX_TOKEN" -H 'content-type: application/json' \ -d '{"model":"xai/grok-4.7","messages":[{"role":"user","content":"hi"}],"max_tokens":16}'
403 {"error":{"message":"The provider denied access to this request.","type":"permission_error","param":null,"code":"permission_denied"}} - Same OAuth access token, straight to the upstream, shows the real cause:
curl -s https://cli-chat-proxy.grok.com/v1/models -H "Authorization: Bearer $ACCESS" # 403 {"error":"Grok Build is not supported in Legacy (no storage). Switch to Privacy Mode to use Grok Build. [WKE=privacy-mode:legacy]"} curl -s "https://cli-chat-proxy.grok.com/v1/billing?format=credits" -H "Authorization: Bearer $ACCESS" # same 403 curl -s https://cli-chat-proxy.grok.com/v1/user -H "Authorization: Bearer $ACCESS" # 200 — credentials are valid; the account is simply in the gated privacy mode
- The 403 is account-scoped, not header-scoped: identical with bearer-only and with the full Grok CLI header set (
x-xai-token-auth: xai-grok-cli,x-grok-client-identifier,x-grok-client-version,x-authenticateresponse). - After switching the account to Privacy Mode in the UI (no opencodex change, same token): discovery returns 200 with 4 models (
grok-4.7,grok-4.7-build-fast,grok-4.6,grok-4.5),ocx provider test xai→connected, and the same gateway request returns 200.
Version
2.100.4
Operating system
macOS 15.6 (arm64)
Provider and model
xai / grok-4.7 — authMode oauth, adapter openai-chat
Logs or error output
# downstream (opencodex)
403 {"error":{"message":"The provider denied access to this request.","type":"permission_error","param":null,"code":"permission_denied"}}
# usage.jsonl for the same request
"status": 403, "errorCode": "permission_denied", "credentialSource": "grok-oauth"
# service.log
Provider model discovery for "xai" failed with HTTP 403 [urlClass=provider-models, fallback=configured]
# upstream (xAI), same token
{"error":"Grok Build is not supported in Legacy (no storage). Switch to Privacy Mode to use Grok Build. [WKE=privacy-mode:legacy]"}
Redacted configuration
{
"xai": {
"adapter": "openai-chat",
"baseUrl": "https://api.x.ai/v1",
"authMode": "oauth",
"defaultModel": "grok-4.7",
"liveModels": true
}
}(For authMode: oauth, resolveProviderTransport rewrites baseUrl to XAI_GROK_CLI_BASE_URL — src/providers/xai-transport.ts:180 — which is why every xAI OAuth request rides the gated Grok Build lane.)
Suggested fix
Detect the stable marker and answer with fixed proxy copy (no upstream bytes echoed, per src/lib/upstream-condition.ts's own contract), for example:
The xAI account is set to Privacy Mode "Legacy (no storage)", which xAI blocks for Grok Build traffic. Switch the account to Privacy Mode (no training) in the xAI/Grok privacy settings, then retry. (provider: xai)
Two implementation notes from reading 2.100.4:
classifyUpstreamConditiononly carries keyword sets for location / verification / billing / model / rate-limit conditions, so an unrecognized 403 lands instatusFallback()→access_denied(lines 87 and 124). A new condition (or an entry inCLIENT_ERROR_CONTRACTS/ACTIONABLE_REFUSALS) keyed on the exact tokenWKE=privacy-mode:legacywould be the narrowest change; a message keyword likeswitch to privacy modecovers the same sentence without the WKE suffix.- Reachability is worth verifying: xAI sends the sentence as
{"error":"<string>"}—erroras a bare string.upstreamErrorMessageFromPayload(src/lib/errors.ts:93) only readserror.message,last_error.message,response.error.message,response.incomplete_details.messageand flat streammessage, so unless the xAI path preserves the raw body text,evidence.messagemay be empty at classification time. Either accept a bare-stringerrorthere or classify from bounded body text in the xAI path.
The same marker also hides two other surfaces that stay silent today: ocx provider test xai ("upstream model discovery returned 403") and the Grok quota probe (GET /v1/billing?format=credits → 403), so the hint is worth reusing in both instead of a generic failure line.
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity