nc://xai-oauth

v0.1.0Pinned
Backnodecode-ai
pomterrecells: thirty-three cells, ported from oh-my-pi -- providers oh-my-pi carries (can1357/oh-my-pi at c9383c1, MIT, credited in each folder's NOTICE), each as a cell of its own: Alibaba's Coding and Token Plans, Amazon Bedrock, Anthropic's Pro/Max sign-in, Apple's on-device Foundation Models (macOS), Azure OpenAI, ClinePass, Cloudflare AI Gateway, Cursor, Devin, Factory Droid, GitHub Copilot, GitLab Duo and its agent, Antigravity, the Gemini CLI's Cloud Code Assist, Vertex AI, Kilo, Kimi Code, local ONNX and MLX workers, Muse Code, Ollama Cloud, ChatGPT's Codex sign-in and its device-code variant, OpenRouter, Snowflake Cortex, xAI's SuperGrok sign-in, Xiaomi MiMo and Z.AI's Coding Plan; and four that are not chat providers: language servers (nodecode-lsp), Perplexity search, keyless web search engines (nodecode-web-provider) and TypeSafe judgments. Each stands alone: it loads, starts, stops and tests by itself, depends only on nodecode, and shares no code with another; one whose wire none of the four lanes speaks registers a lane of its own. Written against the cell contract (src/CELLS.md) at nodecode fb4bdabc1. Their tests ran green against that tree with no network (~/nodecode-cells/tools/test-cell.sh, 663 tests over the 33, 0 failed).914a3fe· 8 Oct1 commit
test1 filecell.lisp5.0 KBprovider.lisp7.7 KBsignin.lisp19.0 KB

nodecode-xai-oauth

A Nodecode cell for xAI Grok on a SuperGrok or X Premium+ subscription. With it, /xai-oauth login signs in to xAI with a device code, /models lists the Grok models the subscription serves (Grok Build, Grok 4.3 to 4.7, the Grok 4.20 SKUs, Grok Composer 2.5 Fast), and a turn on xai-oauth/<model> goes to https://api.x.ai/v1/responses the way oh-my-pi sends it:

  • the access token is the bearer, on the same paid Responses API an xAI key rides
  • reasoning.effort is left out for the models that refuse it (Grok Build, the -reasoning SKUs); elsewhere minimal is sent as low, and xhigh and max as high except on Grok 4.6, 4.7 and 4.20 Multi-Agent, which take xhigh
  • reasoning.summary is never sent, and encrypted reasoning is asked for on every reasoning model so the next round replays it
  • a tool schema whose root is a union of bare required-key fragments loses that union, which xAI refuses (the object stays)
  • the session rides x-grok-conv-id, which xAI's prompt cache routes on

Ported from oh-my-pi's xai-oauth provider, whose sign-in oh-my-pi adapted from NousResearch/hermes-agent. See NOTICE.

Sign-in

/xai-oauth login     answers at once with the address to open and the code to enter
/xai-oauth status    signed in, as whom, and when the token expires
/xai-oauth logout    forgets the sign-in

The device code is asked of https://auth.x.ai with the Grok CLI's client and scopes. The token endpoint is read from xAI's OIDC discovery document at every login and refresh, and refused unless it is https on x.ai or a subdomain, since every refresh token is sent there. The login polls on a background thread and says the outcome as a notice; the userinfo endpoint then names the account's email. The token is kept in the shared auth.json under oauth_tokens.xai-oauth (access_token, refresh_token, expires_at in epoch seconds, account_id, email) and refreshed before a round when it expires within a minute.

Without a sign-in, a token set in XAI_OAUTH_TOKEN, or a key saved with /connect, is used. XAI_API_KEY is not read here (oh-my-pi's dedicated mode), and the Responses lane's own fallback never sends OPENAI_API_KEY to xAI.

Install

Copy this folder into ~/.nodecode/cells/nodecode-xai-oauth/ and restart Nodecode, or run (restart-cells).

Configure

Optional. The section is on unless it says "enabled": false:

{
  "xai-oauth": {
    // where xAI is served
    "base_url": "https://api.x.ai/v1"
  }
}

Test

From this repository's root:

tools/test-cell.sh nodecode-xai-oauth

Not ported

  • Grok Imagine and Grok TTS, which ride image and speech wires, not a chat lane (tools/omp-models.py keeps them out).
  • oh-my-pi's XAI_BASE_URL override, which never applies to an OAuth token anyway; base_url in the section is the knob here.
  • The SuperGrok credit usage report (cli-chat-proxy.grok.com/v1/billing) and oh-my-pi's live model discovery, which merges /v1/models over the curated rows.

Gaps

None found: every rule above rides an existing core seam.

MIT licensed.

Add nc://xai-oauth

  1. 1

    Install Nodecode

    Once per machine.

    $ curl -fsSL https://nodecode.ai/install.sh | sh
  2. 2

    Add the cell

    Pinned at 914a3fe.

    $ nodecode add nc://xai-oauth

    Or tell the agent add the xai oauth cell.

  3. 3

    Sign in

    Run /xai-oauth login and follow what it says.