# Best code sandboxes for AI agents and apps that run user code

URL: https://heaven.dev/compare/best-code-sandboxes-for-ai-agents
Title: Code sandboxes for AI agents - run limits, saved state and cost
Description: Code sandboxes your app or agent starts from an API: how long a run lasts, what survives it, how idle time bills, GPUs and what a month of runs costs.
Checked: November 21, 2026

For short runs your app starts from an SDK, pick E2B: a sandbox pauses with its memory and forks mid-run. Pick Daytona for long runs, big machines, Windows, macOS or GPUs that aren't preempted, and Modal Sandboxes for GPU fan-out from Python with a credit that renews every month. If your app already runs on Vercel or Cloudflare, their sandboxes bill CPU only while it's busy. Pick Blaxel for agents that sleep between calls and wake with their memory, and Northflank for sandboxes with no time limit, beside your services or in your own cloud. Heaven keeps one machine per agent instead of starting fresh runs, so it isn't ranked here.

## How to choose

Five questions decide most of it, and the first two matter most.

- **How long does one run last?** E2B Hobby stops a run at 1 hour and Vercel Hobby at 45 minutes. Daytona and Modal allow 24 hours with no monthly fee, Blaxel keeps a sandbox for 7 days on its first tier, and Northflank sets no limit.

- **What has to survive the run?** E2B's pause and Blaxel's standby keep memory and running processes. Vercel, Modal and Cloudflare bring files back into a new machine, and Daytona and Northflank keep only what you put on a volume.

- **Is the sandbox busy or waiting?** A task that waits on a model costs less on Vercel and Cloudflare, which bill CPU only while it's busy, or on E2B and Blaxel if it pauses between calls. A sandbox that stays busy costs least on Northflank, then about the same on E2B, Daytona and Blaxel.

- **Does it need a GPU, Windows or macOS?** Modal, Daytona and Northflank have GPUs. Only Daytona runs Windows and macOS.

- **Where does the rest of your stack run?** Vercel and Cloudflare sandboxes are driven from apps on those platforms, and Northflank runs beside your services or in your own cloud.

If the agent keeps one machine for weeks and serves what it builds, that isn't a sandbox job. See Heaven at the end of this list, or [best persistent VMs for coding agents](https://heaven.dev/compare/best-persistent-vms-for-coding-agents).

## The best code sandboxes compared

| Product | Best for | Longest run | Kept after a run | While it waits |
| --- | --- | --- | --- | --- |
| **E2B** | Short runs from an SDK that pause and fork | 1 hour, 24 on Pro | Everything, if paused | No compute charge paused |
| **Daytona** | Big machines, GPUs, Windows and macOS | 24 hours, 48 on Team | Volumes and snapshots only | Billed at the reservation while running |
| **Modal Sandboxes** | GPU fan-out from Python, in 19 locations | 24 hours | Snapshots, into a new Sandbox | Billed at the request while running |
| **Vercel Sandbox** | Apps on Vercel, tasks that mostly wait | 45 minutes, 24 hours on Pro | Files, in a fresh VM | Memory billed, CPU only while busy |
| **Blaxel** | Agents that wait between calls | 7 days on Tier 0, 30 on Tier 1 | Everything, in standby | Standby: storage only |
| **Northflank** | Long-lived sandboxes beside your services | No limit | Mounted volumes only | Billed while running, busy or idle |
| **Cloudflare Sandbox** | Commands from a Cloudflare Worker | While active, then up to 6 idle hours | Files, in a beta snapshot | Memory billed, CPU only while busy |

| Product | Isolation | GPUs | Free usage | Driven from |
| --- | --- | --- | --- | --- |
| **E2B** | Firecracker microVM | ✗ | $100 once, commercial use allowed | Python and TypeScript SDKs |
| **Daytona** | Firecracker microVM. Windows and GPUs in VMs | ✓ H100 to B300 and AMD MI355X | $200 once, GPUs excluded | Python and TypeScript SDKs |
| **Modal Sandboxes** | gVisor container or a VM | ✓ T4 to B300. Can be preempted | ✓ $30 every month | Python. JavaScript and Go in beta |
| **Vercel Sandbox** | MicroVM | ✗ | Hobby quotas, non-commercial only | TypeScript and Python SDKs |
| **Blaxel** | Firecracker-based microVM | ✗ | Up to $200 of credits | Python, TypeScript and Go SDKs |
| **Northflank** | MicroVM on CPU, gVisor on GPU | ✓ L4 to B200 | ✓ $20 of resources every month | JavaScript and Python SDKs |
| **Cloudflare Sandbox** | Firecracker microVM | ✗ | Included usage on the $5 Workers Paid plan | TypeScript, inside a Worker |

All seven take your own container image and serve an exposed port at an HTTPS address while the sandbox runs.

## The options

### E2B for short runs that pause and fork

E2B starts a Firecracker microVM from its Python or TypeScript SDK, and a full pause keeps files, memory and processes with no expiry while compute billing stops. Auto-resume wakes a paused sandbox when a request reaches it, a fork copies a running one into up to 20, and the Code Interpreter SDK keeps variables and returns charts as data. Hobby allows commercial use, but stops a run at 1 hour, runs 10 at once and offers only the default 2 vCPU, 512 MiB size. Pro allows 24 hours, 100 at once and sizes up to 8 vCPUs and 8 GiB for $150 a month. See [E2B alternatives](https://heaven.dev/alternatives/e2b).

### Daytona for big machines, GPUs, Windows and macOS

Daytona runs Linux sandboxes on x86 or Arm, Windows, macOS and dedicated GPUs from Python and TypeScript SDKs, with interpreter contexts and computer-use APIs. Starter has no monthly fee, allows any size up to 64 cores and 128 GiB and sessions up to 24 hours, and gives $200 of credit once, GPUs excluded. Team, at $250 a month, raises sessions to 48 hours and makes GPUs non-preemptible. A Linux sandbox is deleted when its session ends, so keep results on a volume or in a snapshot. See [Daytona alternatives](https://heaven.dev/alternatives/daytona).

### Modal Sandboxes for GPU fan-out from Python

Modal starts Sandboxes from Python, or JavaScript and Go in beta, with GPUs from a T4 to a B300 billed by the second, and includes $30 of compute every month on Starter. Sandboxes can be pinned to 19 locations, and tunnels expose raw TCP as well as HTTPS. A Sandbox stops after 5 minutes by default and 24 hours at most, GPU Sandboxes can be preempted, and memory snapshots are in alpha. See [Modal Sandboxes alternatives](https://heaven.dev/alternatives/modal).

### Vercel Sandbox for apps on Vercel

Vercel Sandbox gives each session a microVM from a TypeScript or Python SDK and bills CPU only while it's busy, so a task waiting on a model pays mostly for memory. A named sandbox saves its files when it stops and loads them into a fresh VM, so processes start again, and the firewall can match HTTP method, path and headers. Sessions last 45 minutes on Hobby, which is for non-commercial use, and 24 hours on Pro at $20 a month. An exposed port's URL is open to anyone who has it. See [E2B vs Vercel Sandbox](https://heaven.dev/compare/e2b-vs-vercel-sandbox).

### Blaxel for agents that wait between calls

Blaxel moves a sandbox to standby about 15 seconds after its last connection closes, stops the compute bill and resumes it with memory and processes on the next request, in under 25 ms by Blaxel's figure. Active time bills by allocated memory, CPU follows the memory size, and egress is included. Tier 0 keeps a sandbox for up to 7 days and Tier 1 for 30, and an agent working inside one needs a keep-alive process to stay active. See [Heaven vs Blaxel](https://heaven.dev/compare/heaven-vs-blaxel).

### Northflank for sandboxes beside your services

Northflank runs sandboxes with no time limit beside your app's services, jobs and databases, in 17 managed regions or in your own cloud or Kubernetes cluster. CPU sandboxes are microVMs and GPU sandboxes use gVisor, with GPUs from an L4 to a B200 once you prepay $50 of credit, and its CPU and memory rates are the lowest on this list. A sandbox bills while it runs, busy or idle, and pausing wipes its root disk and processes, so keep files on a mounted volume. The free Sandbox plan includes $20 of resources a month and 2 services. See [Heaven vs Northflank](https://heaven.dev/compare/heaven-vs-northflank).

### Cloudflare Sandbox for commands from a Worker

Cloudflare Sandbox runs a Linux container in its own Firecracker microVM, controlled from a Worker through a TypeScript SDK, and bills memory and disk while it runs and CPU only while it's busy. It stays up while its Durable Object is active and then up to 6 idle hours, and the agent's own processes don't count as activity. When it stops, processes, memory and unsaved files are gone, and a beta snapshot brings files back into the next instance. Instances default to at most 4 vCPUs and 12 GiB, in nine regions, on the $5 Workers Paid plan.

### Also consider Heaven

Heaven, which we make, is cloud infrastructure for software factories. Each agent or app gets a Computer: a full Linux VM with root that keeps running with nobody connected, and a team's Computers share one pool of CPU, memory and storage. Every Computer comes with an HTTPS website with sign-in in front, share links, custom domains, public TCP ports, email, snapshots and hourly off-site backups, and integrations keep GitHub and API credentials outside the machine. Plans start at $20 a month for 2 vCPUs and 8 GiB, with any number of members. See [pricing](https://heaven.dev/pricing).

## Pricing

| Product | Entry plan | What it costs |
| --- | --- | --- |
| **E2B** | Hobby | $0 plus usage, about $0.11 an hour for the default sandbox, with $100 of credit once. Pro is $150 a month |
| **Daytona** | Starter | $0 plus usage, with $200 of credit once. Team is $250 a month |
| **Modal Sandboxes** | Starter | $0 plus usage, with $30 of compute every month. Team is $250 a month |
| **Vercel Sandbox** | Hobby, non-commercial | $0 within its quotas. Pro is $20 a month with $20 of usage |
| **Blaxel** | Pay as you go | $0 plus active time, about $0.041 a GB-hour of memory, with up to $200 of credits |
| **Northflank** | Sandbox | $0 with $20 of resources a month, then $0.0167 a vCPU-hour and $0.0083 a GB-hour |
| **Cloudflare Sandbox** | Workers Paid | $5 a month with some container usage included, then active CPU, memory and disk |

**300 short runs.** Take 300 fresh runs a month, each 10 minutes long with 2 vCPUs, 512 MiB and 2 minutes of busy CPU: 50 hours of sandbox time. E2B Hobby costs **$5.45** and Daytona Starter **$5.46**. Modal's $7.70 fits its monthly credit, so **$0**, and Northflank's $1.88 fits its free allowance. Cloudflare costs **$5.27** on Workers Paid, including its $5 fee, and Blaxel about **$2.07** for each GB of memory a run gets. Vercel needs Pro at **$20**, because the runs use 10 hours of busy CPU against Hobby's 5.

**Sixty 2-hour agent runs.** At 2 vCPUs and 4 GiB, with the CPU busy half the time, that's 120 hours. E2B needs Pro for the size and the length: **$169.87**. Daytona costs **$19.90** and Blaxel **$19.87**. Modal's $28.56 fits its credit, so **$0**, and Northflank's $8.00 fits its allowance. Vercel Pro comes to **$25.54** and Cloudflare to **$17.29** plus disk, because both bill CPU only while it's busy.

A machine held all month, such as Heaven's $20 Tiny plan, costs less than E2B Hobby only above about 1,100 of the short runs.

## Frequently asked questions

### Where does the app my agent builds get served?

From the sandbox while it runs. Each of these products can serve an exposed port at an HTTPS address, Cloudflare through your routing Worker, and on all but Northflank the address goes away when the sandbox stops or expires. To keep an app up for people to open later, deploy it to a host, or run the agent on a persistent machine that keeps its website.

### Does an idle sandbox still cost money?

On most of them, while it runs. E2B, Daytona, Modal Sandboxes and Northflank bill a running sandbox whether or not it's busy. Vercel and Cloudflare bill memory while it waits and CPU only while it works. Pausing on E2B and standby on Blaxel stop the compute bill, and saved files cost a little.

### Why aren't Runloop and Deno Sandbox on this list?

Runloop is winding down and its registration is closed. Deno Sandbox is closed to new customers, and Deno Deploy, which it runs on, is due to shut down in April 2027.

## Related comparisons

See [E2B alternatives](https://heaven.dev/alternatives/e2b), [Daytona alternatives](https://heaven.dev/alternatives/daytona), [Modal Sandboxes alternatives](https://heaven.dev/alternatives/modal), [E2B vs Modal Sandboxes](https://heaven.dev/compare/e2b-vs-modal), [best persistent VMs for coding agents](https://heaven.dev/compare/best-persistent-vms-for-coding-agents) and [infrastructure for software factories](https://heaven.dev/compare/best-infrastructure-for-software-factories).

## Sources and corrections

| Source | Checked |
| --- | --- |
| [E2B pricing](https://e2b.dev/pricing) | November 20, 2026 |
| [E2B plans and limits](https://docs.e2b.dev/billing#plans) | November 19, 2026 |
| [E2B sandbox price](https://docs.e2b.dev/faq/calculate-sandbox-price.md) | November 19, 2026 |
| [E2B quickstart](https://docs.e2b.dev/quickstart.md) | November 19, 2026 |
| [E2B auto-pause and persistence](https://docs.e2b.dev/sandbox/persistence.md) | November 19, 2026 |
| [E2B auto-resume](https://docs.e2b.dev/sandbox/auto-resume.md) | November 19, 2026 |
| [E2B fork](https://docs.e2b.dev/sandbox/fork#create-multiple-forks) | November 20, 2026 |
| [E2B interpreter contexts](https://docs.e2b.dev/code-interpreting/contexts.md) | November 19, 2026 |
| [E2B isolation](https://e2b.dev/index.md) | November 19, 2026 |
| [Daytona pricing](https://www.daytona.com/pricing.md) | November 20, 2026 |
| [Daytona sandbox classes and lifecycle](https://www.daytona.com/docs/sandboxes#lifecycle) | November 20, 2026 |
| [Daytona limits](https://www.daytona.com/docs/limits.md#sandbox-limits) | November 20, 2026 |
| [Daytona billing](https://www.daytona.com/docs/billing#sandbox-billing) | November 20, 2026 |
| [Daytona isolation](https://www.daytona.com/docs/isolation.md) | November 20, 2026 |
| [Daytona GPU sandboxes](https://www.daytona.com/docs/gpu-sandboxes.md) | November 20, 2026 |
| [Daytona interpreter](https://www.daytona.com/docs/python-sdk/interpreter) | November 20, 2026 |
| [Modal pricing](https://modal.com/pricing) | November 19, 2026 |
| [Modal Sandbox timeouts](https://modal.com/docs/guide/sandboxes#timeouts) | November 19, 2026 |
| [Modal runtimes](https://modal.com/docs/guide/sandboxes#runtimes) | November 19, 2026 |
| [Modal Sandbox resources and billing](https://modal.com/docs/guide/sandbox-resources.md) | November 19, 2026 |
| [Modal GPU Sandboxes](https://modal.com/docs/guide/sandbox-resources#gpu-sandboxes) | November 19, 2026 |
| [Modal memory snapshot limits](https://modal.com/docs/guide/sandbox-snapshots#limitations) | November 19, 2026 |
| [Modal tunnels](https://modal.com/docs/guide/tunnels.md#advanced-unencrypted-tcp-tunnels) | November 19, 2026 |
| [Modal regions](https://modal.com/docs/guide/region-selection.md) | November 19, 2026 |
| [Modal JavaScript and Go SDKs](https://modal.com/docs/guide/sdk-javascript-go) | November 19, 2026 |
| [Vercel Sandbox](https://vercel.com/docs/sandbox) | November 19, 2026 |
| [Vercel Sandbox pricing and limits](https://vercel.com/docs/sandbox/pricing) | November 20, 2026 |
| [Vercel Sandbox security](https://vercel.com/docs/sandbox/concepts/security) | November 19, 2026 |
| [Vercel persistent Sandboxes](https://vercel.com/docs/sandbox/concepts/persistent-sandboxes) | November 19, 2026 |
| [Vercel Sandbox Firewall](https://vercel.com/docs/sandbox/concepts/firewall) | November 19, 2026 |
| [Vercel exposed ports](https://vercel.com/docs/sandbox/examples/expose-a-port) | November 19, 2026 |
| [Vercel Hobby terms](https://vercel.com/legal/terms#4-hobby-plan) | November 19, 2026 |
| [Blaxel pricing](https://blaxel.ai/pricing) | November 19, 2026 |
| [Blaxel standby](https://docs.blaxel.ai/Sandboxes/Overview#standby-mode) | November 20, 2026 |
| [Blaxel sandbox sizes](https://docs.blaxel.ai/Sandboxes/Overview.md#active-mode) | November 19, 2026 |
| [Blaxel process keep-alive](https://docs.blaxel.ai/Sandboxes/Processes.md) | November 19, 2026 |
| [Blaxel expiration](https://docs.blaxel.ai/Sandboxes/Expiration) | November 19, 2026 |
| [Blaxel runtime](https://blaxel.ai/blog/anatomy-of-a-runtime) | November 19, 2026 |
| [Blaxel SDKs](https://docs.blaxel.ai/sdk-reference/introduction.md) | November 19, 2026 |
| [Northflank pricing](https://northflank.com/pricing) | November 19, 2026 |
| [Northflank sandboxes](https://northflank.com/product/sandboxes) | November 19, 2026 |
| [Northflank sandbox quickstart](https://northflank.com/docs/v1/application/sandboxes/quickstart) | November 19, 2026 |
| [Northflank sandbox isolation and billing](https://northflank.com/docs/v1/application/sandboxes/sandboxes-on-northflank-cloud) | November 19, 2026 |
| [Northflank pause and resume](https://northflank.com/docs/v1/application/sandboxes/configure-and-manage-sandboxes#pause-and-resume-a-sandbox) | November 19, 2026 |
| [Northflank persistent storage](https://northflank.com/docs/v1/application/sandboxes/examples#create-a-sandbox-with-persistent-storage) | November 19, 2026 |
| [Northflank GPU sandboxes](https://northflank.com/docs/v1/application/sandboxes/examples#create-a-gpu-sandbox) | November 19, 2026 |
| [Northflank GPU plans](https://northflank.com/docs/v1/application/billing/resource-plans-and-quotas#gpu-plans) | November 19, 2026 |
| [Northflank sandboxes in your own cloud](https://northflank.com/docs/v1/application/sandboxes/sandboxes-in-your-own-cloud) | November 19, 2026 |
| [Cloudflare Sandbox SDK](https://developers.cloudflare.com/sandbox/) | November 19, 2026 |
| [Cloudflare Sandbox lifetime](https://developers.cloudflare.com/sandbox/concepts/lifetime/) | November 19, 2026 |
| [Cloudflare Containers pricing](https://developers.cloudflare.com/containers/platform/pricing/) | November 19, 2026 |
| [Cloudflare Containers limits](https://developers.cloudflare.com/containers/platform/limits/) | November 19, 2026 |
| [Cloudflare Container regions](https://developers.cloudflare.com/containers/concepts/placement/#regional-constraints) | November 19, 2026 |
| [Cloudflare Container snapshots](https://developers.cloudflare.com/containers/guides/snapshots/) | November 19, 2026 |
| [Cloudflare Containers isolation](https://blog.cloudflare.com/containers-cross-tenant-vulnerability/) | November 19, 2026 |
| [Cloudflare Sandbox SDK reference](https://developers.cloudflare.com/sandbox/reference/) | November 19, 2026 |
| [Heaven pricing](https://heaven.dev/pricing) | November 21, 2026 |
| [Heaven Computers](https://heaven.dev/docs/computers) | November 21, 2026 |
| [Runloop transition notice](https://docs.runloop.ai/docs/transitions/overview) | November 19, 2026 |
| [Runloop registration](https://platform.runloop.ai/auth/register) | November 19, 2026 |
| [Deno Sandbox availability](https://deno.com/blog/introducing-deno-sandbox#pricing) | November 19, 2026 |
| [Deno Sandbox docs](https://docs.deno.com/sandbox/) | November 19, 2026 |

Spot an error? Email support@heaven.dev with the page, the claim and a source.
