Skip to main content

Coding agents

OpenClaw

Host an OpenClaw agent in a sandbox from the prebuilt openclaw template. Run it headless, or start its gateway and reach the web UI from your browser.

Maintained by
E2B
How it works
Prebuilt openclaw 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 OpenClaw 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 OpenClaw 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 OpenClaw guide at https://docs.e2b.dev/agents/openclaw: create a sandbox from the openclaw template, pass the provider key in envs, and run openclaw agent --local --message headless. 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

    pip install e2b
  2. 2. Set your API keys

    export E2B_API_KEY="e2b_..."
    export ANTHROPIC_API_KEY="..."
  3. 3. Run OpenClaw headless

    import os
    from e2b import Sandbox
    
    sandbox = Sandbox.create("openclaw", envs={
        "ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"],
    })
    
    result = sandbox.commands.run(
        'openclaw agent --local --thinking high --message "Create a hello world HTTP server in Go"',
    )
    
    print(result.stdout)
    sandbox.kill()
  4. 4. Launch the gateway

    sandbox = Sandbox.beta_create("openclaw", envs={
        "ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"],
    }, auto_pause=True, timeout=10 * 60)
    
    sandbox.commands.run("openclaw gateway --port 18789 --verbose")
    
    host = sandbox.get_host(18789)
    print(f"OpenClaw Gateway: https://{host}")

Security

What runs in the sandbox

The OpenClaw agent, its workspace and its gateway all run in the sandbox, not on your machine.

  • Agentopenclaw agent, reading provider keys from the sandbox environment when you pass -⁠-⁠local.
  • WorkspaceSOUL.md, HEARTBEAT.md and skills live in the sandbox workspace. Write them in or install skills with clawhub.
  • GatewayThe web UI and chat interface, served on a sandbox port you open with getHost().
  • LifetimeWith auto-pause on, the sandbox pauses after its timeout and can be resumed later instead of being killed.

3B+ sandboxes started

Give every agent a machine