

























@@ -6,30 +6,74 @@ read_when:
66title: "xAI"
77---
889-OpenClaw ships a bundled `xai` provider plugin for Grok models.
9+OpenClaw ships a bundled `xai` provider plugin for Grok models. For most
10+users, the recommended path is Grok OAuth with an eligible SuperGrok or X Premium
11+subscription. OpenClaw stays local-first: the Gateway, config, routing, and
12+tools run on your machine, while Grok model requests authenticate through xAI
13+and are sent to xAI's API.
101411-## Getting started
15+OAuth does not require an xAI API key, and it does not require the Grok Build
16+app. xAI may still show Grok Build on the consent screen because OpenClaw uses
17+xAI's shared OAuth client.
18+19+## Choose your setup path
20+21+Use the path that matches your OpenClaw install state:
12221323<Steps>
14-<Step title="Choose auth">
15-Use either an API key from the [xAI console](https://console.x.ai/),
16-xAI OAuth browser sign-in with an eligible xAI account, or xAI device-code
17-sign-in for remote/VPS hosts where a localhost browser callback is awkward.
18-OAuth does not require an xAI API key, and OpenClaw does not require the
19-Grok Build app. xAI may still label the consent app as Grok Build because
24+<Step title="New OpenClaw install">
25+Run onboarding with daemon install when you are setting up a new local
26+Gateway, then choose the xAI/Grok OAuth option in the model/auth step:
27+28+```bash
29+openclaw onboard --install-daemon
30+```
31+32+On a VPS or over SSH, use device-code during onboarding:
33+34+```bash
35+openclaw onboard --install-daemon --auth-choice xai-device-code
36+```
37+38+OAuth does not require an xAI API key. OpenClaw does not require the Grok
39+Build app. xAI may still label the consent app as Grok Build because
2040OpenClaw uses xAI's shared OAuth client.
41+2142</Step>
22-<Step title="Sign in">
23-Set `XAI_API_KEY`, run the API-key wizard, or start the OAuth flow:
43+<Step title="Existing OpenClaw install">
44+If OpenClaw is already configured, sign in to xAI only. Do not rerun full
45+onboarding or reinstall the daemon just to connect Grok:
24462547```bash
26-openclaw onboard --auth-choice xai-api-key
27-openclaw onboard --auth-choice xai-oauth
28-openclaw onboard --auth-choice xai-device-code
2948openclaw models auth login --provider xai --method oauth
49+```
50+51+Use the device-code flow instead when the Gateway runs over SSH, Docker, or
52+a VPS and a localhost browser callback is awkward:
53+54+```bash
3055openclaw models auth login --provider xai --device-code
3156```
325758+To make Grok the default model after signing in, apply it separately:
59+60+```bash
61+openclaw models set xai/grok-4.3
62+```
63+64+Rerun full onboarding only if you intentionally want to change Gateway,
65+daemon, channel, workspace, or other setup choices.
66+67+</Step>
68+<Step title="API-key path">
69+API-key setup still works for xAI Console keys and for media surfaces that
70+require key-backed provider config:
71+72+```bash
73+openclaw models auth login --provider xai --method api-key
74+export XAI_API_KEY=xai-...
75+```
76+3377</Step>
3478<Step title="Pick a model">
3579```json5
@@ -42,9 +86,9 @@ OpenClaw ships a bundled `xai` provider plugin for Grok models.
42864387<Note>
4488OpenClaw uses the xAI Responses API as the bundled xAI transport. The same
45-credential from `openclaw onboard --auth-choice xai-api-key` or
46-`openclaw onboard --auth-choice xai-oauth` /
47-`openclaw onboard --auth-choice xai-device-code` can also power first-class
89+credential from `openclaw models auth login --provider xai --method oauth`,
90+`openclaw models auth login --provider xai --device-code`, or
91+`openclaw models auth login --provider xai --method api-key` can also power first-class
4892`x_search`, remote `code_execution`, and xAI image/video generation.
4993Speech and transcription currently require `XAI_API_KEY` or provider config.
5094`XAI_API_KEY` or plugin web-search config can power Grok-backed `web_search` too.
@@ -55,6 +99,22 @@ and, by default, `x_search` through an operator xAI Responses proxy.
5599`code_execution` tuning lives under `plugins.entries.xai.config.codeExecution`.
56100</Note>
57101102+## OAuth troubleshooting
103+104+- If browser OAuth cannot reach `127.0.0.1:56121`, use
105+`openclaw models auth login --provider xai --device-code`.
106+- If sign-in succeeds but Grok is not the default model, run
107+`openclaw models set xai/grok-4.3`.
108+- To inspect saved xAI auth profiles, run:
109+110+```bash
111+ openclaw models auth list --provider xai
112+ openclaw models status
113+```
114+115+- xAI decides which accounts can receive OAuth API tokens. If an account is not
116+ eligible, try the API-key path or check the subscription on xAI's side.
117+58118<Tip>
59119Use `xai-device-code` when signing in from SSH, Docker, or a VPS. OpenClaw
60120prints an xAI URL and short code; finish sign-in in any local browser while the
@@ -427,11 +487,12 @@ Legacy aliases still normalize to the canonical bundled ids:
427487428488<Accordion title="Known limits">
429489- xAI auth can use an API key, environment variable, plugin config fallback,
430- or xAI OAuth browser sign-in with an eligible xAI account. OAuth uses a
431- local callback on `127.0.0.1:56121`; for remote hosts, forward that port
432- before opening the sign-in URL. xAI decides which accounts can receive
433- OAuth API tokens, and the consent page may show Grok Build even though
434- OpenClaw does not require the Grok Build app.
490+ browser OAuth, or device-code OAuth with an eligible xAI account. Browser
491+ OAuth uses a local callback on `127.0.0.1:56121`; for remote hosts, use
492+ `xai-device-code` unless you want to forward that port before opening the
493+ sign-in URL. xAI decides which accounts can receive OAuth API tokens, and
494+ the consent page may show Grok Build even though OpenClaw does not require
495+ the Grok Build app.
435496- `grok-4.20-multi-agent-experimental-beta-0304` is not supported on the
436497 normal xAI provider path because it requires a different upstream API
437498 surface than the standard OpenClaw xAI transport.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。