Skip to content

feat(providers): add xAI Grok OAuth with capability-gated X Search - #5035

Merged
chengyongru merged 13 commits into
HKUDS:mainfrom
chengyongru:feat/xai-premium-oauth
Jul 23, 2026
Merged

chengyongru merged 13 commits into
HKUDS:mainfrom
chengyongru:feat/xai-premium-oauth

Conversation

@chengyongru

@chengyongru chengyongru commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add native OAuth 2.0 + PKCE sign-in for eligible xAI Grok subscriptions, with isolated token storage, proactive refresh, and one forced refresh after HTTP 401
  • add an xAI Grok Responses provider for grok-4.5; hosted x_search is sent only when /v1/models advertises supportsBackendSearch
  • support provider-scoped proxy configuration and bounded, credential-redacted upstream error bodies
  • integrate the provider across the registry, factory, CLI, config, WebUI, documentation, and tests
  • omit reasoning.effort when reasoningEffort is "none", preventing xAI from rejecting background requests such as chat-title generation
  • keep WebUI controls focused on sign-in state and proxy configuration; detailed behavior remains in the documentation

Usage

nanobot provider login xai-grok --set-main

The default model is xai-grok/grok-4.5 with a 500,000-token context window.

Surface Name
CLI and model prefix xai-grok
Provider / preset ID xai_grok
JSON config key xaiGrok
WebUI label xAI Grok

Security and failure behavior

  • validates OAuth state, issuer, discovered endpoint hosts, and callback origin; uses PKCE and a random loopback callback port
  • stores OAuth credentials atomically outside config.json; this integration does not use an xAI API key or X Developer OAuth
  • refreshes proactively, retries once after HTTP 401, and redacts credential-shaped fields and bearer values before logging bounded upstream errors
  • caches model capabilities for five minutes and fails closed when the catalog cannot be read, leaving hosted X Search disabled

Verification

  • focused Python regression: 241 passed, 1 skipped
  • focused WebUI regression: 94 passed
  • Python lint and WebUI lint passed
  • production WebUI build passed
  • real Gateway + Playwright check passed for the Models route, xAI Grok naming, provider controls, and reload persistence; old public names were absent

Upstream references

@chengyongru chengyongru added priority: p1 Important user-impacting issue or project priority with bounded impact or a reasonable workaround. feature enhancement New feature or request provider new-provider webui documentation Improvements or additions to documentation test security labels Jul 22, 2026
@chengyongru chengyongru changed the title feat(providers): add xAI subscription OAuth with hosted X Search feat(providers): add xAI subscription OAuth with capability-gated X Search Jul 22, 2026
@chengyongru chengyongru changed the title feat(providers): add xAI subscription OAuth with capability-gated X Search feat(providers): add xAI Grok OAuth with capability-gated X Search Jul 22, 2026
chengyongru and others added 11 commits July 23, 2026 11:17
Add PKCE-based xAI account authentication, a Grok Responses provider with hosted X Search, and matching CLI, WebUI, configuration, documentation, and test coverage.
Expose provider-scoped proxy settings for xAI OAuth and OpenAI Codex while keeping OAuth credentials read-only.
Return Bad Gateway for xAI OAuth transport and upstream errors so WebUI authentication failures remain distinguishable from gateway token rejection.
@chengyongru
chengyongru merged commit c7393c7 into HKUDS:main Jul 23, 2026
5 checks passed
okwillbe pushed a commit to okwillbe/nanobot that referenced this pull request Aug 15, 2026
StefanoParadisi pushed a commit to StefanoHernandez/nanobot that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request feature new-provider priority: p1 Important user-impacting issue or project priority with bounded impact or a reasonable workaround. provider security test webui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant