Skip to content

Commit dbb75a0

Browse files
docs: add Grok Build agent page (#287)
* docs: add Grok agent page Add agents/grok.mdx documenting the pre-built `grok` sandbox template, mirroring amp.mdx's structure (CLI, headless with -p/--always-approve, cloned-repo example, streaming JSON, custom template). Register it in docs.json navigation and add the grok.svg icon. * docs: fix grok icon fill so it renders in the sidebar The icon used fill=currentColor which renders blank in the Mintlify icon slot. Use an explicit neutral fill like the codex icon so it shows in both light and dark themes, matching how amp hardcodes its brand color. * docs: rename Grok page to Grok Build Use the product name Grok Build and the grok-build template id (e2b sbx create grok-build). The binary invoked inside the sandbox stays grok. * docs: rename template id back to grok Per review, the template id is grok (e2b sbx create grok). Keeps the Grok Build product name in the title and prose; the binary stays grok.
1 parent 471f69b commit dbb75a0

3 files changed

Lines changed: 189 additions & 0 deletions

File tree

docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"docs/agents/codex",
6464
"docs/agents/crabbox",
6565
"docs/agents/devin",
66+
"docs/agents/grok",
6667
"docs/agents/openai-agents-sdk",
6768
{
6869
"group": "OpenClaw",

docs/agents/grok.mdx

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
title: "Grok Build"
3+
description: "Run Grok Build in a secure E2B sandbox with full filesystem, terminal, and git access."
4+
icon: "/images/icons/grok.svg"
5+
---
6+
7+
[Grok Build](https://x.ai/cli) is xAI's coding agent and CLI. E2B provides a pre-built `grok` template with Grok Build already installed.
8+
9+
## CLI
10+
11+
Create a sandbox with the [E2B CLI](/docs/cli).
12+
13+
```bash
14+
e2b sbx create grok
15+
```
16+
17+
Once inside the sandbox, start Grok Build.
18+
19+
```bash
20+
grok
21+
```
22+
23+
## Run headless
24+
25+
Use `-p` for non-interactive mode and `--always-approve` to auto-approve all tool calls (safe inside E2B sandboxes). Grok Build authenticates with an API key from the [xAI console](https://console.x.ai) via the `XAI_API_KEY` environment variable.
26+
27+
<CodeGroup>
28+
```typescript JavaScript & TypeScript
29+
import { Sandbox } from 'e2b'
30+
31+
const sandbox = await Sandbox.create('grok', {
32+
envs: { XAI_API_KEY: process.env.XAI_API_KEY },
33+
})
34+
35+
const result = await sandbox.commands.run(
36+
`grok --always-approve -p "Create a hello world HTTP server in Go"`
37+
)
38+
39+
console.log(result.stdout)
40+
await sandbox.kill()
41+
```
42+
```python Python
43+
import os
44+
from e2b import Sandbox
45+
46+
sandbox = Sandbox.create("grok", envs={
47+
"XAI_API_KEY": os.environ["XAI_API_KEY"],
48+
})
49+
50+
result = sandbox.commands.run(
51+
'grok --always-approve -p "Create a hello world HTTP server in Go"',
52+
)
53+
54+
print(result.stdout)
55+
sandbox.kill()
56+
```
57+
</CodeGroup>
58+
59+
### Example: work on a cloned repository
60+
61+
<CodeGroup>
62+
```typescript JavaScript & TypeScript
63+
import { Sandbox } from 'e2b'
64+
65+
const sandbox = await Sandbox.create('grok', {
66+
envs: { XAI_API_KEY: process.env.XAI_API_KEY },
67+
timeoutMs: 600_000,
68+
})
69+
70+
await sandbox.git.clone('https://github.com/your-org/your-repo.git', {
71+
path: '/home/user/repo',
72+
username: 'x-access-token',
73+
password: process.env.GITHUB_TOKEN,
74+
depth: 1,
75+
})
76+
77+
const result = await sandbox.commands.run(
78+
`cd /home/user/repo && grok --always-approve -p "Add error handling to all API endpoints"`,
79+
{ onStdout: (data) => process.stdout.write(data) }
80+
)
81+
82+
const diff = await sandbox.commands.run('cd /home/user/repo && git diff')
83+
console.log(diff.stdout)
84+
85+
await sandbox.kill()
86+
```
87+
```python Python
88+
import os
89+
from e2b import Sandbox
90+
91+
sandbox = Sandbox.create("grok", envs={
92+
"XAI_API_KEY": os.environ["XAI_API_KEY"],
93+
}, timeout=600)
94+
95+
sandbox.git.clone("https://github.com/your-org/your-repo.git",
96+
path="/home/user/repo",
97+
username="x-access-token",
98+
password=os.environ["GITHUB_TOKEN"],
99+
depth=1,
100+
)
101+
102+
result = sandbox.commands.run(
103+
'cd /home/user/repo && grok --always-approve -p "Add error handling to all API endpoints"',
104+
on_stdout=lambda data: print(data, end=""),
105+
)
106+
107+
diff = sandbox.commands.run("cd /home/user/repo && git diff")
108+
print(diff.stdout)
109+
110+
sandbox.kill()
111+
```
112+
</CodeGroup>
113+
114+
## Build a custom template
115+
116+
If you need to customize the environment (e.g. pre-install dependencies, add config files), build your own template on top of the pre-built `grok` template.
117+
118+
<CodeGroup>
119+
```typescript JavaScript & TypeScript
120+
// template.ts
121+
import { Template } from 'e2b'
122+
123+
export const template = Template()
124+
.fromTemplate('grok')
125+
```
126+
```python Python
127+
# template.py
128+
from e2b import Template
129+
130+
template = (
131+
Template()
132+
.from_template("grok")
133+
)
134+
```
135+
</CodeGroup>
136+
137+
<CodeGroup>
138+
```typescript JavaScript & TypeScript
139+
// build.ts
140+
import { Template, defaultBuildLogger } from 'e2b'
141+
import { template as grokTemplate } from './template'
142+
143+
await Template.build(grokTemplate, 'my-grok', {
144+
cpuCount: 2,
145+
memoryMB: 2048,
146+
onBuildLogs: defaultBuildLogger(),
147+
})
148+
```
149+
```python Python
150+
# build.py
151+
from e2b import Template, default_build_logger
152+
from template import template as grok_template
153+
154+
Template.build(grok_template, "my-grok",
155+
cpu_count=2,
156+
memory_mb=2048,
157+
on_build_logs=default_build_logger(),
158+
)
159+
```
160+
</CodeGroup>
161+
162+
Run the build script to create the template.
163+
164+
<CodeGroup>
165+
```bash JavaScript & TypeScript
166+
npx tsx build.ts
167+
```
168+
```bash Python
169+
python build.py
170+
```
171+
</CodeGroup>
172+
173+
## Related guides
174+
175+
<CardGroup cols={3}>
176+
<Card title="Sandbox persistence" icon="clock" href="/docs/sandbox/persistence">
177+
Auto-pause, resume, and manage sandbox lifecycle
178+
</Card>
179+
<Card title="Git integration" icon="code-branch" href="/docs/sandbox/git-integration">
180+
Clone repos, manage branches, and push changes
181+
</Card>
182+
<Card title="SSH access" icon="terminal" href="/docs/sandbox/ssh-access">
183+
Connect to the sandbox via SSH for interactive sessions
184+
</Card>
185+
</CardGroup>

images/icons/grok.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)