Grok CLI Manual
Configuration
Most Grok configuration problems come from the file path, TOML nesting, or the model definition that is actually active.
Configuration paths
| Environment | Configuration file |
|---|---|
| Linux / macOS | ~/.grok/config.toml |
| Native Windows | %USERPROFILE%\.grok\config.toml |
| WSL2 | ~/.grok/config.toml inside WSL |
Show the configuration Grok actually reads:
grok inspectMain sections
| Section | Purpose |
|---|---|
[models] | Select the default model |
[endpoints] | Set separate base addresses for model requests and Imagine image/video tools |
[model."<id>"] | Define model ID, key, backend, and context window |
[auth] | Select OAuth or API Key authentication |
[session] | Control session behavior and automatic compaction |
[ui] | Control the interface, tool approval, and compact mode |
Model and Imagine endpoints are separate
[endpoints]
models_base_url = "https://api.example.com"
xai_api_base_url = "https://api.example.com"
[auth]
preferred_method = "api_key"models_base_url handles model discovery and primary inference requests. image_gen, image_edit, image_to_video, and reference_to_video read xai_api_base_url separately. Set both fields to the same main API origin without /v1; direct API calls still use the standard /v1/... paths. If a Grok OAuth session already exists, preferred_method = "api_key" prevents it from replacing the Router Key. See Image Generation and Editing and Video Generation for complete examples.
Common session and UI settings
[session]
# The official default is 85; 80 compacts earlier
auto_compact_threshold_percent = 80
[ui]
max_thoughts_width = 120
yolo = true
compact_mode = false
permission_mode = "always-approve"yolo and always-approve reduce tool-confirmation prompts. Use them only with trusted projects in a local environment that you can roll back.
The official reference also states:
GROK_HOMEchanges the config directory. A project-level.grok/config.tomlis read only for[mcp_servers],[plugins], and[permission]; every other section must live in the user config.permission_modeacceptsdefault,ask,auto, oralways-approve;max_thoughts_widthranges from 40 to 500.api_backendacceptschat_completions,responses, ormessages.- The legacy
[ui] show_timestampsis replaced bytimestamps(off,minimal,on). - The reference page describes endpoint overrides through the
GROK_MODELS_BASE_URLandGROK_XAI_API_BASE_URLenvironment variables and does not list[endpoints]oryolo. This site keeps the configuration shape that has been verified in use; after upgrading, confirm it withgrok inspect.
See the Grok CLI settings reference for all available fields.