Switch from E2B
Runtime's sandboxes do what E2B's do, with pause and resume that keep memory, forks of a running sandbox, and CPU billed on use ($0.03 per busy vCPU-hour). Most code moves by renaming calls.
| E2B | Runtime |
|---|---|
Sandbox.create() |
POST /v2/sandboxes |
sbx.commands.run(cmd) |
POST /v2/sandboxes/{id}:exec, which returns a non-zero exitCode instead of throwing |
sbx.commands.run(cmd, { background: true }) |
POST /v2/sandboxes/{id}:exec with wait false |
sbx.files.write(path, data) |
PUT /v2/sandboxes/{id}/files |
sbx.files.read(path) |
GET /v2/sandboxes/{id}/files |
sbx.getHost(port) |
POST /v2/sandboxes/{id}/previews, private by default |
sbx.betaPause(), Sandbox.connect(id) |
POST /v2/sandboxes/{id}:pause, POST /v2/sandboxes/{id}:resume |
sbx.kill() |
DELETE /v2/sandboxes/{id} |
| Templates | snapshots |
Before and after#
E2B:
TypeScriptimport { Sandbox } from "e2b";const sbx = await Sandbox.create();await sbx.files.write("/home/user/step.py", "print(21 * 2)");const r = await sbx.commands.run("python3 /home/user/step.py");console.log(r.stdout);await sbx.kill();Runtime:
TypeScriptimport { Runtime } from "withruntime";const runtime = new Runtime();const sbx = await runtime.sandboxes.create({});try { await runtime.sandboxes.write(sbx.id, new TextEncoder().encode("print(21 * 2)"), { path: "/tmp/step.py" }); const r = await runtime.sandboxes.exec(sbx.id, { cmd: ["python3", "/tmp/step.py"] }); console.log(r.stdout); // 42 if (r.stdout.trim() !== "42") throw new Error(r.stderr);} finally { await runtime.sandboxes.delete(sbx.id);}What changes besides the names:
- Commands run as the user
runtimein/workspace, withsudoand no password; there is no/home/user. POST /v2/sandboxes/{id}:exectakes the program and its arguments as a list. For a shell line, pass["bash", "-c", line].- A sandbox with nothing happening pauses by itself and the next call resumes it, so there is no timeout to keep extending. See pause and resume.
Give this to your agent#
Paste this into your coding agent:
Read https://withruntime.com/docs/switch-from-e2b.md. Replace every E2B call in this project with its Runtime call, on a branch, remove the E2B SDK, run the project's tests and its real job on Runtime, and fix what fails. Never delete the E2B account or its keys.
This page as Markdown: https://withruntime.com/docs/switch-from-e2b.md
Try it on your own work.Signing up takes no card. Your first sandbox asks for one, and the trial starts then. Or paste the setup prompt into your agent.