Skip to main content

Coding agents

Pi

Run the Pi coding agent in a sandbox from the prebuilt pi template. Pi reads, edits and runs commands without prompts, so the sandbox keeps all of it off your machine.

Maintained by
E2B
How it works
Prebuilt pi sandbox template
Package
e2b
Language
TypeScript, Python

Set it up

Get started

Paste the prompt into your coding agent, or follow the steps yourself.

Paste this into your coding agent

Run Pi in an E2B sandbox from this project.

  1. 1.Install the e2b SDK using the project's package manager.
  2. 2.The SDK needs the E2B_API_KEY environment variable, and Pi needs a model provider key such as ANTHROPIC_API_KEY. If E2B_API_KEY isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode either key.
  3. 3.Follow the Pi guide at https://docs.e2b.dev/agents/pi: create a sandbox from the pi template, pass the provider key in envs, and run pi -p "<task>" in print mode. Kill the sandbox when it's done.
  4. 4.Run one task and show me the output that came from the sandbox.

Or set it up yourself

  1. 1. Install the E2B SDK

    npm init -y && npm pkg set type=module
    npm install e2b
    npm install -D tsx
  2. 2. Set your API keys

    export E2B_API_KEY="e2b_..."
    export ANTHROPIC_API_KEY="..."
  3. 3. Run Pi in print mode

    import { Sandbox } from 'e2b'
    
    const sandbox = await Sandbox.create('pi', {
      envs: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
    })
    
    const result = await sandbox.commands.run(
      `pi -p "Create a hello world HTTP server in Go"`
    )
    
    console.log(result.stdout)
    await sandbox.kill()

Security

What runs in the sandbox

Pi and every file edit and shell command it makes stay inside the sandbox.

  • AgentPi in print mode. It shows no permission prompts for its built-in tools, so none need auto-approving.
  • FilesThe repo you clone and every change Pi makes. Read the result back with git diff.
  • SecretsPi can't reach your host files or credentials. Only the provider key you pass in envs is there.
  • NetworkInternet access is on by default. Limit it with outbound rules by CIDR or hostname.

3B+ sandboxes started

Give every agent a machine