overview.md +43 −84
2 2
3# Grok Build3# Grok Build
4 4
55Grok Build is a powerful and extensible coding agent. Use it via an interactive TUI, headlessly in scripts or bots, or through the Agent Client Protocol (ACP) in other apps.Grok Build is a coding agent for the terminal. Use it as an interactive TUI, headlessly in scripts or bots, or through the Agent Client Protocol (ACP) in other apps.
6
7The TUI provides a rich, mouse-interactive, fullscreen experience for coding with agents.
8 6
9## Install7## Install
10 8
9Run the command for your system. It downloads the latest stable release and adds `grok` to your `PATH`:
10
11```bash customLanguage="bashMacLinux"11```bash customLanguage="bashMacLinux"
12curl -fsSL https://x.ai/cli/install.sh | bash12curl -fsSL https://x.ai/cli/install.sh | bash
13```13```
16irm https://x.ai/cli/install.ps1 | iex16irm https://x.ai/cli/install.ps1 | iex
17```17```
18 18
1919## Start an interactive session## Run Grok
20
21Start Grok in your project folder:
20 22
21```bash customLanguage="bash"23```bash customLanguage="bash"
22cd your-project24cd your-project
23grok25grok
24```26```
25 27
2628On first launch, Grok opens a browser for authentication. In non-browser environments, use an API key:If your shell can't find `grok`, open a new terminal.
27 29
2830```bash customLanguage="bash"On first launch, Grok opens your browser to sign in, and keeps you signed in after that. If there is no browser, use another method:
29export XAI_API_KEY="xai-..."
30grok
31```
32 31
3332Useful first prompts:| Where you're working | Sign in with | Command |
33| -------------------- | ------------ | ------- |
34| Your own machine | Browser | `grok` |
35| SSH or a remote machine | Device code | `grok login --device-auth` |
36| CI and scripts | API key | `export XAI_API_KEY="xai-..."` |
34 37
3538```textFor every sign-in option, see [Authentication](/build/enterprise#authentication).
36Explain this repo.
37@src/main.rs Walk me through this file.
38```
39
40## Run headlessly
41
42```bash customLanguage="bash"
43grok -p "Explain this codebase"
44grok -p "Explain the architecture" --output-format streaming-json
45```
46 39
4740Headless usage is ideal for scripts, automations, or integration into other apps.## Ask your first question
48 41
4942## Custom modelsAt the prompt, start with a question that works in any repository:
50
51Grok supports any custom model. Add it to your user-level config file, `~/.grok/config.toml` (on Windows, `%USERPROFILE%\.grok\config.toml`):
52 43
53```text44```text
5445[model.my-model]Explain this repo.
55model = "model-id"
56base_url = "https://api.example.com/v1"
57name = "Display Name"
58env_key = "API_KEY"
59
60[models]
61default = "my-model"
62```46```
63 47
6448After updating `~/.grok/config.toml`, use `grok inspect` to see what Grok discovered in the current directory, including config sources, instructions, skills, plugins, hooks, and MCP servers, then pick the model in headless mode or in the TUI:Grok reads the files it needs, shows each step as it runs, and answers with a summary of the codebase. Once you see that, the install, sign-in and project are all working.
65
66```bash customLanguage="bash"
67grok inspect
68grok -p "Hello" -m my-model
69```
70 49
7150You can also switch inside the TUI with `/model <name>`.Then point it at a file with `@`:
72 51
7352## Use Grok 4.7 on the API```text
53@src/main.rs Walk me through this file.
54```
74 55
7556[`grok-4.7`](/developers/models/grok-4.7), SpaceXSI's latest model, is available directly on the xAI API. Drop it into your own agent loop, IDE integration, or coding tool.In a session, `/usage` shows your credit usage.
76 57
7758```javascript customLanguage="javascriptAISDK"## Run headlessly
78import { xai } from '@ai-sdk/xai';
79import { generateText } from 'ai';
80 59
8160const { text } = await generateText({Headless mode is ideal for scripts, automations, or integration into other apps:
82 model: xai.responses('grok-4.7'),
83 prompt: 'Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}',
84});
85 61
8662console.log(text);```bash customLanguage="bash"
63grok -p "Explain this codebase"
64grok -p "Explain the architecture" --output-format streaming-json
87```65```
88 66
8967```python customLanguage="pythonOpenAISDK"For its flags and output formats, see [Headless and Scripting](/build/cli/headless-scripting).
90from openai import OpenAI
91 68
9269client = OpenAI(## Update
93 api_key="<YOUR_XAI_API_KEY_HERE>",
94 base_url="https://api.x.ai/v1",
95)
96 70
9771response = client.responses.create(One command updates Grok for both interactive and headless use:
98 model="grok-4.7",
99 input="Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",
100)
101
102print(response.output_text)
103```
104 72
105```bash customLanguage="bash"73```bash customLanguage="bash"
10674curl https://api.x.ai/v1/responses \grok update
107 -H "Authorization: Bearer $XAI_API_KEY" \
108 -H "Content-Type: application/json" \
109 -d '{
110 "model": "grok-4.7",
111 "input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
112 }'
113```75```
114 76
11577```python customLanguage="pythonXAI"To see what each release changed, read the [Changelog](https://x.ai/changelog/build).
116import os
117from xai_sdk import Client
118from xai_sdk.chat import user
119 78
12079client = Client(api_key=os.getenv("XAI_API_KEY"))## Requirements
121 80
12281chat = client.chat.create(model="grok-4.7")* macOS (Apple silicon or Intel) or Linux (x86\_64 or arm64). On Windows, use PowerShell, Git Bash or WSL.
12382chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))* A terminal, and a project folder to run Grok in.
12483 * A SpaceXSI account to sign in with, or an API key.
125print(chat.sample().content)
126```
127 84
128## Features85## Features
129 86
13087* [Status Line](/build/features/status-line). Live session context in a row at the bottom of the TUI.* [Plugins, skills](/build/features/skills-plugins-marketplaces) and [MCP servers](/build/features/mcp-servers). Extend what Grok can do.
13188* [Skills, Plugins & Marketplaces](/build/features/skills-plugins-marketplaces)* [Agent Dashboard](/build/features/dashboard). Every session at a glance, and which agents need input.
13289* [Modes and Commands](/build/modes-and-commands)* [Modes and Commands](/build/modes-and-commands). Switch modes with Shift+Tab and use slash commands.
90* [CLI Reference](/build/cli/reference). The `grok` subcommands and common flags.
133 91
134## Next92## Next
135 93
13694* [Headless & Scripting](/build/cli/headless-scripting)* [Custom Models](/build/settings/reference#modelid). Use any model through `~/.grok/config.toml`.
95* [Grok 4.7 on the API](/developers/grok-4-7#using-the-api). Call the model from your own agent or tool.
137* [Enterprise Deployments](/build/enterprise)96* [Enterprise Deployments](/build/enterprise)
138* [Grok Bot](/grok-bot/overview) — AI teammates on a cloud computer97* [Grok Bot](/grok-bot/overview) — AI teammates on a cloud computer