pi template with Pi already installed.
CLI
Create a sandbox with the E2B CLI./login to authenticate with a supported subscription provider, or provide an API key through an environment variable.
Run headless
Use-p for non-interactive print mode. Pi does not show permission prompts for its built-in tools, so no auto-approval flag is needed. The sandbox isolates Pi from your host machine, but sandboxes can reach the open internet by default — restrict outbound traffic with network rules.
Pi supports multiple model providers. The examples below use Anthropic through the ANTHROPIC_API_KEY environment variable.
Pi can read and modify files and run shell commands directly. E2B contains those operations inside the sandbox, so Pi cannot access your host files or credentials. It can still make outbound network requests — use outbound network rules to limit access by CIDR or hostname. Hostname rules apply to HTTP(S) traffic only; use CIDR rules for other protocols.
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-builtpi template.
Related guides
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