Updated:
Grok Build Setup
Grok Build is xAI's terminal coding assistant. This guide connects it to Grok models through Cubence's OpenAI-compatible endpoint.
Base URL and routes
The examples use the Mainland China route, https://api-lb.cubence.ai/v1. For global use, set the Base URL to https://api.cubence.ai/v1; outside Mainland China, you can use https://api.cubence.com/v1. Keep /v1 and any request path when switching routes. See API endpoints and Base URL configuration.
Installation
Run the Official Installer
Open PowerShell and run:
irm https://x.ai/cli/install.ps1 | iexVerify the Installation
Reopen PowerShell, then run:
grok --versionRun the Official Installer
Open a terminal and run:
curl -fsSL https://x.ai/cli/install.sh | bashVerify the Installation
Reopen the terminal, then run:
grok --versionConfiguration
Create the Configuration File
Grok Build reads %USERPROFILE%\.grok\config.toml. Create the directory and open the file from PowerShell:
New-Item -ItemType Directory -Force "$env:USERPROFILE\.grok"
notepad "$env:USERPROFILE\.grok\config.toml"Grok Build reads ~/.grok/config.toml. Create the directory and open the file with your preferred editor:
mkdir -p ~/.grok
nano ~/.grok/config.tomlAdd the Cubence Model
Paste the following configuration into config.toml:
[models]
default = "grok-4.6"
web_search = "grok-4.6"
[endpoints]
models_base_url = "https://api-lb.cubence.ai/v1"
[model."grok-4.6"]
model = "grok-4.6"
name = "Grok 4.6"
description = "Grok 4.6 via Cubence"
api_key = "your-api-key-here"
api_backend = "responses"
context_window = 500000
supports_reasoning_effort = trueReplace your-api-key-here with your Cubence API Key. Never share or commit your real key, screenshots containing it, or your completed configuration file.
The settings above select grok-4.6 for normal and web-search requests, send model traffic to Cubence's /v1 endpoint, use the Responses API backend, declare a 500,000-token context window, and enable Grok Build's reasoning-effort controls.
Store the API Key in an Environment Variable
For safer secret handling, replace the api_key line with:
env_key = "CUBENCE_API_KEY"Then set CUBENCE_API_KEY in your operating system, shell profile, or secret manager before starting Grok Build.
$env:CUBENCE_API_KEY = "your-api-key-here"export CUBENCE_API_KEY="your-api-key-here"env_key must contain the environment-variable name, not the API Key itself. The commands above apply only to the current terminal session; use your system's secure environment or secret storage for persistence.
Verify the Connection
First inspect the configuration Grok Build loaded:
grok inspectThen send a minimal request:
grok -p "Reply with ok only" -m grok-4.6The response should be ok. If it is, Grok Build is using the configured Cubence model successfully.
Change Reasoning Effort
In the interactive terminal UI, change the current effort level with one of these commands:
/effort low
/effort medium
/effort high
/effort xhighYou can also select a model and effort together:
/model grok-4.6 highFor a headless request, pass --effort:
grok -p "Reply with ok only" -m grok-4.6 --effort highThese controls require supports_reasoning_effort = true and a model that supports reasoning effort.
Troubleshooting
- API Key is not detected: Use
api_key = "..."for an inline key, or setenv_key = "CUBENCE_API_KEY"and define that environment variable before launching Grok Build. - Model or permission error: Confirm the Cubence key has access to the selected model, the endpoint uses your selected route with
/v1(such ashttps://api-lb.cubence.ai/v1for Mainland China), the model name is correct, and the key has no missing characters or surrounding whitespace. /effortis unavailable: Confirmsupports_reasoning_effort = true, verify that the model supports effort controls, save the file, and restart Grok Build.
Having Issues?
Check the FAQ, or get help through pre-sales and after-sales support.