---
title: "OpenClaw integration"
description: "Host an OpenClaw agent in an E2B sandbox: run it headless, add skills from ClawHub, or start its gateway and open the web UI from your browser."
url: "https://e2b.dev/integrations/openclaw"
---

# 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.

Coding agents · [All integrations](https://e2b.dev/integrations.md)

## About this integration

- **Maintained by:** E2B
- **How it works:** Prebuilt openclaw sandbox template
- **Package:** e2b
- **Language:** TypeScript, Python
- **Upstream:** [openclaw/openclaw · ★ 395k](https://github.com/openclaw/openclaw)
- **Docs:** [docs.e2b.dev/agents/openclaw](https://docs.e2b.dev/agents/openclaw)

## Get started

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

### Paste this into your coding agent

```text
Run OpenClaw in an E2B sandbox from this project.

1. Install the e2b SDK using the project's package manager.
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. 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. Run one task and show me the output that came from the sandbox.
```

## Or set it up yourself

### 1. Install the E2B SDK

```bash
pip install e2b
```

### 2. Set your API keys

```bash
export E2B_API_KEY="e2b_..."
export ANTHROPIC_API_KEY="..."
```

### 3. Run OpenClaw headless

```python
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. Launch the gateway

```python
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}")
```

## What runs in the sandbox

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

- **Agent:** openclaw agent, reading provider keys from the sandbox environment when you pass --local.
- **Workspace:** SOUL.md, HEARTBEAT.md and skills live in the sandbox workspace. Write them in or install skills with clawhub.
- **Gateway:** The web UI and chat interface, served on a sandbox port you open with getHost().
- **Lifetime:** With auto-pause on, the sandbox pauses after its timeout and can be resumed later instead of being killed.

## More coding agents

Other coding agents that run in E2B sandboxes.

- [Hermes Agent](https://e2b.dev/integrations/hermes.md): Run Hermes Agent in a sandbox template, or keep it local and execute its terminal tools on E2B.
- [Claude Code](https://e2b.dev/integrations/claude-code.md): Run Claude Code in its own sandbox with a real filesystem, terminal, and git, so it can work unattended.
- [Pi](https://e2b.dev/integrations/pi.md): Run the Pi coding agent in a sandbox, or keep Pi local and send its tool calls to E2B with @e2b/pi.

## Links

- [Get API key](https://console.e2b.dev/?tab=keys)
- [Read the docs](https://docs.e2b.dev/agents/openclaw)
- [E2B documentation](https://docs.e2b.dev)
