Skip to main content
Grok Build is xAI’s coding agent and CLI. E2B provides a pre-built grok template with Grok Build already installed.

CLI

Create a sandbox with the E2B CLI.
Once inside the sandbox, start Grok Build.

Run headless

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 via the XAI_API_KEY environment variable.

Example: work on a cloned repository

Build a custom template

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.
Run the build script to create the template.

Sandbox persistence

Auto-pause, resume, and manage sandbox lifecycle

Git integration

Clone repos, manage branches, and push changes

SSH access

Connect to the sandbox via SSH for interactive sessions