# Runtime vs E2B Runtime runs agent code in Firecracker microVMs, like E2B. It costs **77% less** for an agent that spends most of its time waiting on a model. **The saving:** 1,000 one-minute runs of a 2 vCPU, 4 GiB sandbox cost **$0.64 on Runtime and $2.76 on E2B**. At 100,000 runs a month that is $63.89 against $276.00, **$212 a month saved**. Your E2B code keeps working. Change one import. Comparing more than two? [E2B alternatives](/compare/e2b-alternatives) ranks the other providers by the cost of the same job. ## Where Runtime is better - **You pay for the CPU you use.** E2B bills every vCPU for as long as the sandbox runs. Runtime measures the CPU your code actually uses. Time spent waiting on a model costs only a small floor, a twentieth of a vCPU. - **Waiting costs storage, not compute.** A Runtime sandbox left idle for 300 seconds pauses by itself and keeps its memory. It then pays $0.08 per GB (10⁹ bytes) a month until a request wakes it. - **A written uptime promise.** 99% API uptime a month for paid accounts, measured from outside. 10% of a short month's charges comes back as credit automatically ([Uptime Promise](/legal/sla)). - **Lower rates on both meters.** $0.025 per vCPU-hour against E2B's $0.0504, and $0.0075 per GiB-hour of memory against $0.0162. Even with every CPU busy the whole time, the example job costs $1.33 on Runtime and $2.76 on E2B. - **No plan fee for long sessions.** E2B caps a session at 1 hour on Hobby and needs the $150-a-month Pro plan for 24. A Runtime sandbox has no time limit. It runs while it works. It needs no plan. You add prepaid credit from $10. - **A one-line switch.** `withruntime/e2b` runs code written for E2B's SDK, in JavaScript and Python, including the code interpreter. Credit you add within 30 days of signing up is matched, up to $1,000 in total. - **Teams at no extra charge.** Single sign-on over SAML or OIDC (Okta, Microsoft Entra ID, Google Workspace), SCIM, roles and an audit log come with every account ([single sign-on](./single-sign-on)). E2B lists SSO, SCIM and roles as planned for its Enterprise plan. - **OpenTelemetry export on every account.** Runtime pushes events as logs, and CPU and memory as metrics, to any OTLP endpoint at no charge ([observability](./observability#opentelemetry-export)). E2B sends OTLP metrics and logs on its Enterprise plan. - **Custom domains built in.** A paid account serves a sandbox port at your own hostname, with HTTPS, from one command ([custom domains](./networking#custom-domains)). E2B's custom domain guide has you run your own proxy on a virtual machine. - **Secrets stay outside the sandbox.** Code inside sees a placeholder. The real key is added at the egress proxy, only on HTTPS to the hosts you allow ([security](./security)). - **Your agent sets itself up.** It runs `npx withruntime sandboxes run -- ...`, shows you a link, and starts once you approve in the browser. No API key goes into a prompt or a config file. The [MCP server](./mcp) reuses the same connection. - **Guardrails for agents.** Give an agent a read-only key or a daily spending limit per key. Cap any sandbox's whole cost with `maxTotalCostMicros`. Every write takes an idempotency key, and the SDKs retry with it. A lost response never creates a second sandbox. **Also included:** a code interpreter, network allow and deny lists, custom images, volumes backed up daily, snapshots and forks with memory, private previews, a Linux desktop, metrics, webhooks, S3, R2 and GCS bucket mounts, MCP servers from a catalog and identity tokens for AWS and Google Cloud. Paid accounts add TCP ports, dedicated outbound addresses and WireGuard private networks. See [products](./products). ## At a glance E2B's figures come from its public pricing and documentation, checked 25 October 2026. | | Runtime | E2B | | ---------------- | --------------------------------------------------------------------------- | -------------------------------------------------------- | | Isolation | Firecracker microVM, own kernel | Firecracker microVM, own kernel | | CPU billing | $0.025 per vCPU-hour of measured CPU, with a small floor | $0.0504 per allocated vCPU-hour | | Memory billing | $0.0075 per reserved GiB-hour | $0.0162 per GiB-hour | | Plan fee | None; prepaid credit from $10 | Hobby $0; Pro $150 a month | | Free start | 100 free hours of a 1 GB machine in the first 30 days, no card | $100 of usage credit on Hobby | | Session length | No time limit: runs while it works, pauses itself after 300 seconds idle | 1 hour on Hobby, 24 hours on Pro | | Pause and resume | Files, memory and running processes | Files, memory and running processes | | Interfaces | API, CLI, MCP server, JavaScript, Python, Go, Ruby and Java SDKs | API, CLI, MCP server, JavaScript and Python SDKs | | Agent sign-in | Browser approval; no key in the agent's config | API key | | Port URLs | Private with a token by default | Public to anyone with the URL unless you turn on a token | ## Cost for the same job Take 1,000 runs of a 2 vCPU, 4 GiB sandbox. Each run lasts 60 seconds and keeps the CPU busy for 20 CPU-seconds. This is an agent that spends most of its time waiting for a model. ``` Runtime CPU 1,000 × 20 s / 3,600 × $0.025 = $0.14 Memory 1,000 × 60 s / 3,600 × 4 × $0.0075 = $0.50 Total $0.64 E2B CPU 1,000 × 60 s / 3,600 × 2 × $0.0504 = $1.68 Memory 1,000 × 60 s / 3,600 × 4 × $0.0162 = $1.08 Total $2.76 ``` - **Saving:** 77%, or $2.12 per 1,000 runs. - **Per month:** at 100,000 runs, $63.89 on Runtime against $276.00 on E2B. - **Busier work:** with both CPUs busy for the whole minute, $1.33 on Runtime against $2.76 on E2B. At this size, Runtime is cheaper however busy the sandbox is. Plan fees, storage, network, taxes and free credits are left out of both. `runtime compare --from e2b` prices your own usage the same way. Sandboxes the free usage paid for count at the standard rates, so free usage never counts as a saving. On Runtime, inbound traffic is free. Each account's first 100 GiB out a month is free. After that, outbound traffic costs $0.02 per GB (10⁹ bytes). See [pricing](./pricing) for Runtime's terms. ## How to switch Give your coding agent the one instruction in [migration](./migrate). It replaces the E2B calls on a branch, tests them on the free usage, and tells you what you save each month. Your old code stays on the main branch until you merge. ### Change one import Runtime's SDK runs code written for E2B's SDK, as this page describes from version 0.12.0 (Python 0.12.0). Change the import and set `RUNTIME_API_KEY`: ```ts no-run import { Sandbox } from "withruntime/e2b"; // was: from "e2b" ``` ```python no-run from withruntime.e2b import Sandbox # was: from e2b import Sandbox ``` `withruntime/e2b/code-interpreter` and `withruntime.e2b.code_interpreter` replace E2B's code interpreter packages. Sandboxes get E2B's defaults: 2 vCPU and 512 MiB. Runtime's server stores the `timeoutMs` you give, up to 24 hours. When it runs out, the sandbox is deleted, as E2B kills it. `kill()` also deletes it. With no timeout, E2B's 300 seconds ends in a pause instead. The pause keeps memory and files at $0.08 per GB (10⁹ bytes) a month while the account has credit. So call `kill()` when the work is done. Unlike E2B's, sandboxes pause after 300 seconds with nothing happening and wake on the next call. E2B code still sees them running. `runtime: { create: { idlePauseSeconds: 0 } }` keeps them running. Sandboxes use the free usage first, then prepaid credit. There is nothing to choose. `commands.run` returns the command's whole output. As E2B's does, it throws `CommandExitError` (Python `CommandExitException`) on a non-zero exit. It throws `TimeoutError` (Python `TimeoutException`) past its timeout. Your existing error handling keeps working. If any output was lost before it was read, the result's `truncated` is set, and a warning says so. A call Runtime handles differently, such as E2B templates, workload identity or ending a sandbox earlier than its time limit, throws `NotSupportedError` before anything happens. It names what to use instead. `E2B.md` in the package lists every mapping. ### Or port the calls The calls map one to one for most integrations. E2B: ```js import { Sandbox } from "e2b"; const sbx = await Sandbox.create(); const result = await sbx.commands.run("python3 -c 'print(sum([125, 250, 375]))'"); await sbx.kill(); ``` Runtime: ```ts import { Sandbox } from "withruntime"; const box = await Sandbox.create(); try { await box.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n"); console.log((await box.exec("python3 /workspace/invoice.py", { check: true })).stdout); } finally { await box.stop(); } ``` E2B's `commands.run` throws `CommandExitError` on a non-zero exit. Runtime's `exec` returns the result with `exitCode` (and `timedOut: true` on a timeout). With `{ check: true }`, as above, it throws `CommandError` instead. ## When E2B may fit better - **Self-hosting.** E2B publishes its runtime under Apache-2.0, so you can run it on your own servers. Runtime is a hosted service. ## Sources Checked 23 September 2026; single sign-on, OpenTelemetry and custom domains checked 27 September 2026; port URLs checked 3 November 2026. - [E2B pricing](https://e2b.dev/pricing) - [E2B Enterprise](https://e2b.dev/enterprise) - [E2B custom domain](https://docs.e2b.dev/sandbox/custom-domain) - [E2B sandbox persistence](https://docs.e2b.dev/sandbox/persistence) - [E2B security](https://e2b.dev/security) - [E2B public URLs](https://docs.e2b.dev/network/public-url) - Runtime [pricing](./pricing), [security](./security) and [products](./products)