xAI Auth And Setup
Grok Code is xAI-only in this build. If xAI is not configured, the product still opens, but most real work stays blocked until you connect an API key.
Ways To Provide Credentials
You can authenticate in any of these ways:
- the TUI wizard with
/connect - the CLI with
grok login - environment variables such as
XAI_API_KEY - config values in
~/.grok/config.toml
Optional management access can come from:
XAI_MANAGEMENT_API_KEY- the management key field in
/connect
The Recommended Setup Flow
Use the TUI:
/connectThe guided flow has five user-facing stages:
Setup: current readiness and next stepAPI Key: paste a new key or keep the existing oneAdvanced: optional management key, region, response storageModel: choose the working model and profileReadyorRepair: close when ready, or fix auth if validation failed
If your current key is already valid, you can leave the API key field blank and continue.
CLI Setup
If you want a simple terminal prompt instead of the TUI:
grok loginWhat it does:
- prompts for the API key
- validates it against the current xAI endpoint
- stores it locally
- keeps your current default model selection
Check the result:
grok whoamiAdvanced Settings In /connect
Region
The wizard offers:
Auto (global)us-east-1eu-west-1
grok whoami shows the effective endpoint after you save.
Response Storage
You can leave remote response storage on or turn it off.
Practical rule:
- leave it on unless you have a reason to disable it
- if you change it, verify the final state with
grok whoami
Management Key
The management key is optional. Grok Code will show whether it is:
- env-managed
- stored
- not configured
Model, Profiles, And Reasoning
Grok Code separates model choice from routing profile.
Model Choice
Common xAI models in this build include:
grok-code-fast-1- Grok 4.20 reasoning and non-reasoning variants
- Grok 4.1 Fast reasoning and non-reasoning variants
grok-4.20-multi-agent
Profile Choice
Profiles are routing presets. The most important user-visible ones are:
BalancedResearch fastResearch deep
Important behavior:
grok-code-fast-1manages reasoning internally- xAI multi-agent depth is profile-driven, not controlled by a separate
/thinkinglevel - some model families expose a reasoning/non-reasoning toggle instead of a free-form effort setting
Inspect Current Auth And Runtime State
Use:
grok whoamiIt shows:
- connection status
- effective endpoint
- selected model
- whether the runtime is using local tools or server-side research behavior
- response storage
- region
- management key presence
Inside the TUI, Control and /status give the same kind of readiness context.
Common Auth States
Not Connected
What it means:
- Grok Code cannot find a usable xAI key
What to do:
- use
/connect - or run
grok login - or set
XAI_API_KEY
Invalid
What it means:
- a stored or provided key failed validation
What to do:
- reopen
/connect - follow the repair flow
- paste a fresh key
Rate-Limited
What it means:
- one or more stored xAI accounts are temporarily blocked
What to do:
- run
grok waitto inspect or wait for recovery - if you rotate between local keys, Grok Code can sometimes stay usable through another ready account
Unsupported Auth Paths
- OAuth is unavailable in the xAI-only build
- voice input is disabled and does not provide an alternate auth path
If setup still feels wrong after all of this, start with Troubleshooting.