BUILD / set-grok-build-environment-variables

Build

Set Grok Build environment variables

Set Grok Build environment variables

Session and CI overrides for Grok Build live in GROK_* (and related) environment variables. Full table: Settings Reference — Environment variables. Persistent defaults belong in ~/.grok/config.toml or $GROK_HOME/config.toml — see Settings.

Paths and auth

Variable Default Use
GROK_HOME ~/.grok Home for config, auth, sessions, skills, plugins, logs
XAI_API_KEY API key for CI / headless when you are not using browser login
export XAI_API_KEY="xai-..."
grok -p "Review this diff" --output-format json --always-approve

Models and updates

Variable What it does
GROK_DEFAULT_MODEL Session default model (same idea as -m)
GROK_WEB_SEARCH_MODEL Model used by the client web_search tool
GROK_MODELS_BASE_URL Custom inference base URL
GROK_XAI_API_BASE_URL xAI API base for API-key auth (default https://api.x.ai/v1)
GROK_DISABLE_AUTOUPDATER Suppress auto-updater for this process (CI/containers)

Headless scripts can also pass --no-auto-update once, or set auto_update = false under [cli] in config — see Headless & Scripting.

Tools, sandbox, and features

Variable Default What it does
GROK_SANDBOX off Sandbox profile (workspace, read-only, strict, or custom)
GROK_WEB_FETCH 0 Enable the web_fetch tool (1/0); off by default
GROK_MEMORY 0 Enable cross-session memory
GROK_SUBAGENTS 0 Enable subagents / the task tool
GROK_WRITE_FILE 1 Set 0 for read-only sessions
GROK_LSP_TOOLS 0 Enable the LSP code-intel tool

Proxy traffic uses standard HTTPS_PROXY / HTTP_PROXY / NO_PROXY. MCP startup timeouts: GROK_MCP_STARTUP_TIMEOUT_SECS (seconds) or Claude-compatible MCP_TIMEOUT (milliseconds).

Cursor / Claude scanners

GROK_CURSOR_* and GROK_CLAUDE_* flags (skills, rules, agents, MCPs, hooks) default on. Set one to 0 / false when you need a clean Grok-only load. Confirm with grok inspect.

Priority vs config files

Environment variables are one scope among several (env → user config → project → managed → requirements). Pins in /etc/grok/requirements.toml win over env for compliance-critical settings — see Deploy Grok Build for enterprise. After changing env or TOML, run grok inspect to see what actually loaded.