Skip to content

[Bug]: xAI privacy-mode gate (403 WKE=privacy-mode:legacy) is reported as generic "provider denied access" instead of the actionable switch-to-Privacy-Mode fix #8892

Closed

Description

@3014203030

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).

  1. ocx provider test xai
    → xai: failed / upstream model discovery returned 403
  2. 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"}}
  3. 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
  4. 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).
  5. 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:

  1. classifyUpstreamCondition only carries keyword sets for location / verification / billing / model / rate-limit conditions, so an unrecognized 403 lands in statusFallback() → access_denied (lines 87 and 124). A new condition (or an entry in CLIENT_ERROR_CONTRACTS / ACTIONABLE_REFUSALS) keyed on the exact token WKE=privacy-mode:legacy would be the narrowest change; a message keyword like switch to privacy mode covers the same sentence without the WKE suffix.
  2. Reachability is worth verifying: xAI sends the sentence as {"error":"<string>"} — error as a bare string. upstreamErrorMessageFromPayload (src/lib/errors.ts:93) only reads error.message, last_error.message, response.error.message, response.incomplete_details.message and flat stream message, so unless the xAI path preserves the raw body text, evidence.message may be empty at classification time. Either accept a bare-string error there 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

  1. added
    bug
    account-pool
    provider
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolbugprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions