Grok Build
Grok Build 是一个强大且可扩展的编码智能体。通过交互式 TUI、在脚本或机器人中无头运行, 或通过 Agent Client Protocol (ACP) 在其他应用中使用。
TUI 提供了丰富的、鼠标交互的全屏编码智能体体验。
安装
macOS / Linux / WSL
curl -fsSL https://x.ai/cli/install.sh | bash启动交互式会话
Bash
cd your-project
grok首次启动时,Grok 会打开浏览器进行身份验证。在无浏览器环境中,使用 API Key:
有用的首次提示:
# 解释当前仓库
Explain this repo.
# 查看特定文件
@src/main.rs Walk me through this file.无头运行
基本用法
grok -p "Explain this codebase"无头模式非常适合脚本、自动化或集成到其他应用中。
自定义模型
Grok 支持任何自定义模型。将其添加到用户级配置文件 ~/.grok/config.toml(在 Windows 上为 %USERPROFILE%\.grok\config.toml):
config.toml
[model.my-model]
model = "model-id"
base_url = "https://api.example.com/v1"
name = "Display Name"
env_key = "API_KEY"
[models]
default = "my-model"更新 ~/.grok/config.toml 后,使用 grok inspect 查看 Grok 在当前目录中发现的内容, 包括配置源、指令、技能、插件、钩子和 MCP 服务器,然后在无头模式或 TUI 中选择模型:
你也可以在 TUI 中使用 /model <name> 切换模型。
在 API 上使用 Grok 4.5
驱动 Grok Build 的同一模型 grok-4.5 也可直接在 xAI API 上使用。 将其放入你自己的智能体循环、IDE 集成或编码工具中。
cURL
curl https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.5",
"input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}'