Grok CLI is xAI's command-line coding agent. This guide shows how to install the official CLI, configure ApiPass as the model endpoint, and start using Grok 4.5 from your terminal.
Make sure you have:
The installer and configuration commands below run in macOS, Linux, and WSL2 shells. If you use Windows, run them inside WSL2 rather than native PowerShell.
Install the official Grok CLI:
1curl -fsSL https://x.ai/cli/install.sh | bashAfter the installer finishes, open a new terminal so your updated PATH is loaded.
Grok CLI reads its user configuration from ~/.grok/config.toml.
Create the configuration directory:
1mkdir -p ~/.grokCreate or replace ~/.grok/config.toml with the following configuration:
1[cli]
2installer = "internal"
3
4[models]
5default = "grok-4.5"
6web_search = "grok-4.5"
7
8[endpoints]
9models_base_url = "https://api.apipass.dev/grok-build/v1"
10
11[model."grok-4.5"]
12model = "grok-4.5"
13name = "Grok 4.5"
14description = "Grok 4.5 ApiPass"
15api_key = "api-key"
16api_backend = "responses"
17context_window = 1000000Replace api-key with the API key copied from your ApiPass API Keys page. Keep the quotation marks around the key.
You can also create the file directly from your terminal:
1cat > ~/.grok/config.toml << 'EOF'
2[cli]
3installer = "internal"
4
5[models]
6default = "grok-4.5"
7web_search = "grok-4.5"
8
9[endpoints]
10models_base_url = "https://api.apipass.dev/grok-build/v1"
11
12[model."grok-4.5"]
13model = "grok-4.5"
14name = "Grok 4.5"
15description = "Grok 4.5 ApiPass"
16api_key = "api-key"
17api_backend = "responses"
18context_window = 1000000
19EOFIf you use the terminal command, edit the file afterward and replace api-key with your real ApiPass API key:
1nano ~/.grok/config.tomlBecause the file contains your API key, restrict its permissions:
1chmod 600 ~/.grok/config.toml[cli] keeps CLI updates on the internal installer channel.[models] selects grok-4.5 for normal prompts and web-search requests.[endpoints] routes model discovery and Responses API requests through ApiPass.[model."grok-4.5"] registers the static Grok 4.5 model and stores the ApiPass API key used to authenticate requests.api_backend = "responses" makes the CLI use the Responses API protocol supported by the ApiPass Grok Build endpoint.context_window = 1000000 declares the model's one-million-token context window.Use the base URL exactly as shown:
1https://api.apipass.dev/grok-build/v1Do not append /responses to models_base_url. Grok CLI adds the model and Responses API paths automatically.
Inspect the active Grok CLI configuration:
1grok inspectConfirm that grok-4.5 is available and that the configured endpoint is https://api.apipass.dev/grok-build/v1.
Send a one-off prompt to verify the complete connection:
1grok -p "Reply with exactly: ApiPass connected" -m grok-4.5Open an interactive Grok session in your current project:
1grokYou can also run a single prompt from the command line:
1grok -p "Review this repository and suggest the highest-impact improvement." -m grok-4.5The default model setting lets interactive sessions use Grok 4.5 without passing -m each time.
ApiPass deducts credits when Grok CLI sends requests through the Grok Build endpoint. The exact amount depends on token usage and the active ApiPass pricing rules.
Use these pages to inspect your account and request activity:
grok: command not foundClose and reopen your terminal after running the installer. If the command is still unavailable, follow the installer's PATH instructions and then open another terminal session.
Confirm that the file exists in the same user account and environment where you run Grok CLI:
1ls -l ~/.grok/config.tomlIf you use WSL2, the configuration belongs in the WSL home directory. A file created in the native Windows user profile will not be loaded by the CLI running inside WSL2.
Open ~/.grok/config.toml and confirm that api_key contains an active ApiPass API key, not the placeholder value:
1api_key = "YOUR_APIPASS_API_KEY"Create or manage keys on the ApiPass API Keys page.
Confirm that models_base_url includes /grok-build/v1 and does not include /responses:
1models_base_url = "https://api.apipass.dev/grok-build/v1"The Grok Build CLI endpoint is separate from the general Grok API endpoint, so use the URL shown above for this configuration.
model refresh failedSome Grok CLI versions can display a non-blocking model refresh failed warning when a custom models_base_url is configured. The static [model."grok-4.5"] entry still allows Grok 4.5 requests to work.
Run the one-off verification prompt to confirm the connection:
1grok -p "Reply with exactly: ok" -m grok-4.5Use the exact model identifier grok-4.5 in all three configuration locations:
1default = "grok-4.5"
2web_search = "grok-4.5"
3[model."grok-4.5"]