# Moving from E2B

> Move E2B sandboxes to Prized sandboxes: the Prized command for each E2B SDK call, a short ported script, and what is not on Prized yet.

URL: https://prized.dev/docs/moving-from-e2b

## 1. Export an API key [#1-export-an-api-key]

An E2B sandbox becomes a Prized [sandbox](https://prized.dev/docs/sandboxes): a Firecracker microVM that boots in seconds, pauses with its processes running, and forks into live copies. Make a key with **Sandboxes: Write** on the [API keys page](https://prized.dev/dashboard/workspace/api-keys), then export it in place of `E2B_API_KEY`:

```bash
export PRIZED_API_KEY=dcp_…
```

## 2. Swap each call [#2-swap-each-call]

| E2B | Prized |
| --- | --- |
| `Sandbox.create(timeout=3600)` | `prized sandbox create --max-runtime 1h` |
| `cpu_count`, `memory_mb` on a template build | `prized sandbox create --vcpu 2 --memory 4`, per sandbox |
| `envs={...}` on the create | `prized sandbox create --env NAME=value` |
| `sbx.commands.run(cmd)` | `prized sandbox exec ID -- CMD` |
| `sbx.files.write()`, `files.read()` | `prized sandbox cp ./app.py ID:app.py`, and the reverse |
| `sbx.pause()`, `Sandbox.connect(id)` | `prized sandbox pause ID --wait`, `prized sandbox resume ID`; any command resumes it too |
| `sbx.fork(count=3)` | `prized sandbox fork ID --count 3` |
| `Sandbox.list()` | `prized sandbox ls` |
| `sbx.kill()` | `prized sandbox rm ID` |
| User `user` in `/home/user` | User `prized` in `/home/prized`; commands start in `/home/prized/work` |

Each command has an HTTP route that takes the same key ([Sandbox API](https://prized.dev/docs/sandboxes-api)).

## 3. Port a script [#3-port-a-script]

There is no SDK to install: save the standard-library helper, which wraps the [Sandbox API](https://prized.dev/docs/sandboxes-api) in E2B-shaped calls.

```bash
curl -fsSLO https://prized.dev/skills/prized-sandboxes/scripts/prized_sandbox.py
```

```python title="job.py"
from prized_sandbox import Sandbox  # was: from e2b import Sandbox

sbx = Sandbox.create(max_runtime_min=60)  # was: Sandbox.create(timeout=3600)
copies = []
try:
    sbx.write("/home/prized/work/main.py", b"print(6 * 7)")  # was: sbx.files.write()
    r = sbx.exec("python3 main.py")  # was: sbx.commands.run("python3 main.py")
    print(r["exitCode"], r["stdout"], end="")  # 0 42
    sbx.pause()
    print(sbx.exec("python3 main.py")["stdout"], end="")  # resumes it; was: sbx.connect()
    copies = sbx.fork(2)  # was: sbx.fork(count=2)
    print([c.exec("python3 main.py")["stdout"] for c in copies])
finally:
    for s in [*copies, sbx]:  # copies before their parent
        try:
            s.delete()  # was: sbx.kill()
        except Exception as e:  # keep going: one failed delete must not skip the rest
            print("delete failed:", s.id, e)
```

A failed command does not raise as in E2B: read `exitCode`. `exec` takes `cwd`, `env`, and `timeout` in seconds (300 by default, 3,600 at most).

## Not on Prized yet [#not-on-prized-yet]

* **Docker, custom templates, and root.** Sandboxes start from two fixed templates as `prized`, without sudo, so a template build, `apt`, and Docker need a [box](https://prized.dev/docs/boxes).
* **Lives past 24 hours.** A sandbox is deleted 24 hours after its create, paused or not, and `maxRuntimeMin` is set only at the create; E2B keeps a paused sandbox until you kill it.
* **Regions.** Sandboxes run in US West (Oregon), `us-west-2`, only.
* **Streaming, stdin, and a code interpreter.** A command answers when it ends, and each one is a new process, so keep state between commands in files.
* **Public URLs to ports, SSH, snapshots, volumes, network allow and deny lists, and webhooks.**

## Getting help moving [#getting-help-moving]

Email the support address shown on https://prized.dev/docs/troubleshooting with what you run on E2B, and we will help you map it.
