Grok CLI Manual
Use YAI Router
One config.toml connects Grok CLI to grok-4.5 through YAI Router and grok-cloud.
Copy a configuration with your Key filled in
Open the YAI Router configuration guide and find Grok CLI. The signed-in page inserts your current Key automatically, ready to copy.
The corresponding ~/.grok/config.toml structure is:
[models]
default = "grok-4.5"
[endpoints]
models_base_url = "https://api.yairouter.com"
[model."grok-4.5"]
model = "grok-4.5"
name = "Grok 4.5"
api_key = "sk-Xvs..."
api_backend = "responses"
context_window = 500000
supports_backend_search = true
[session]
auto_compact_threshold_percent = 80
[ui]
max_thoughts_width = 120
yolo = true
compact_mode = false
permission_mode = "always-approve"Set models_base_url to the YAI Router main domain. Set api_key to your YAI Router user Key, not a Grok OAuth refresh_token.
Restrict the file on Linux / macOS:
chmod 600 ~/.grok/config.tomlSkip the chmod command on Windows.
Verify the CLI
grok inspect
grok models
grok --model grok-4.5 --output-format json -p 'Reply with YAI_GROK_OK only'Verify the Responses API
curl https://api.yairouter.com/responses \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-Xvs...' \
-d '{"model":"grok-4.5","input":"Reply with YAI_GROK_API_OK only"}'The CLI and API use the same YAI Router Key and main domain. context_window = 500000 follows the value on the xAI Grok 4.5 model page.