---
title: Vercel Sandbox vs Modal Sandboxes
description: Compare Vercel Sandbox and Modal Sandboxes as AI agent sandboxes, including isolation, persistence, network controls, GPUs, SDKs, and deployment regions.
keywords: ["Vercel Sandbox","Modal Sandboxes","AI agent sandbox","untrusted code execution","Firecracker microVM","gVisor"]
url: "https://vercel.com/kb/guide/vercel-sandbox-vs-modal-sandboxes"
published: 2026-11-23
last_updated: 2026-11-23
authors: Ben Sabic
related_resources:
  - title: "Vercel Sandbox vs Upstash Box"
    url: "/kb/guide/vercel-sandbox-vs-upstash-box"
    description: "Compare Vercel Sandbox and Upstash Box as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment regions."
  - title: "Vercel Sandbox vs Cloudflare Sandbox"
    url: "/kb/guide/vercel-sandbox-vs-cloudflare-sandbox"
    description: "Compare Vercel Sandbox and Cloudflare Sandbox as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment options."
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest kb search "<query>"
read_with_vercel_cli: "npx vercel@latest kb inspect vercel-sandbox-vs-modal-sandboxes"
---

[Vercel Sandbox](https://vercel.com/docs/sandbox) and [Modal Sandboxes](https://modal.com/docs/guide/sandboxes) are AI sandboxes for running generated code in Linux environments. Vercel gives every sandbox a Firecracker microVM with its own kernel. Modal supports gVisor and a VM runtime with its own Linux kernel. Set `runtime` per Sandbox to choose between them.

Choose Vercel Sandbox for automatic file persistence, a dedicated kernel per sandbox, request-level credential controls, or regional snapshot storage. Choose Modal for in-sandbox GPUs, resource bursting, or a shared platform for sandboxes, model inference, and Python functions.

## How Vercel Sandbox and Modal compare

This comparison covers Modal Sandboxes, the `modal.Sandbox` interface for running untrusted code. Modal also offers Functions, Servers, and Endpoints for deploying your own code and models, which use a different execution model.

### Compute and resources

Vercel gives each sandbox [its own Firecracker microVM and kernel](https://vercel.com/docs/sandbox/concepts/security). Modal isolates each Sandbox with one of [two runtimes](https://modal.com/docs/guide/sandboxes#runtimes). With `runtime="gvisor"`, gVisor handles the Sandbox's system calls in user space instead of passing them to the host kernel. The VM runtime, selected with `runtime="vm"`, runs the Sandbox in a virtual machine with its own Linux kernel on the KVM hypervisor.

For a separate kernel on Modal, explicitly select the VM runtime.

| Concern                 | Vercel Sandbox                                                                                                               | Modal Sandboxes                                                                                                                                                           |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Isolation               | Firecracker microVM with its own kernel                                                                                      | gVisor or a VM with its own Linux kernel; set `runtime` explicitly to choose                                                                                              |
| Base environment        | [Ubuntu or Arch images](https://vercel.com/docs/sandbox/concepts/images), or a custom OCI image in Vercel Container Registry | [Modal Image](https://modal.com/docs/guide/images) built in code, from a Dockerfile, or from a [public or private registry](https://modal.com/docs/guide/existing-images) |
| vCPUs                   | 1 vCPU or an even number; default 2. Maximums: 4 (Hobby), 8 (Pro), 32 (Enterprise).                                          | Fractional physical cores, where 1 core equals 2 vCPUs. Default request of 0.125 cores, bursting up to 16 cores above the request unless you set a limit.                 |
| Memory                  | 2 GB per vCPU. Limits: Hobby 8 GB, Pro 16 GB, Enterprise 64 GB.                                                              | Default request of 128 MiB, bursting when the host has spare memory. Optional hard limit.                                                                                 |
| GPUs                    | No GPU option                                                                                                                | [Nvidia GPUs](https://modal.com/docs/guide/gpu), T4 through B300; gVisor only                                                                                             |
| Disk                    | 64 GB of ephemeral NVMe with SDK 3.0.0+ or a custom image                                                                    | 512 GiB quota for each container, which can't be raised for Sandboxes. The VM runtime has a fixed 512 GiB root filesystem.                                                |
| Concurrent environments | Hobby: 10. Pro and Enterprise: 10,000.                                                                                       | Starter: 100 containers. Team: 5,000. Enterprise: custom.                                                                                                                 |
| SDKs and tools          | TypeScript SDK, sync/async Python SDK, Sandbox CLI, Vercel CLI, and Vercel REST API                                          | Sync/async Python SDK, JavaScript/TypeScript and Go SDKs (both in beta), and the `modal` CLI                                                                              |
| Authentication          | Project-scoped Vercel OIDC token, or an access token with team and project IDs                                               | API token ID and secret, read from `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` or `~/.modal.toml`                                                                           |
| Plan                    | Hobby, Pro, and Enterprise                                                                                                   | Starter, Team, and Enterprise                                                                                                                                             |

Vercel's default universal image includes Node.js 24 and Python 3.14 on Ubuntu 26.04. On Modal, you choose the Image for each Sandbox, and Modal recommends [named Images](https://modal.com/docs/guide/named-images) built ahead of time so that Sandbox creation never waits on a build.

The two products size a sandbox differently. Vercel provisions a fixed shape of 1 to 32 vCPUs with 2 GB of memory per vCPU, depending on your plan. Modal treats the `cpu` and `memory` values as a guaranteed minimum and lets a Sandbox [burst above them](https://modal.com/docs/guide/sandbox-resources) when the host has capacity. Modal counts physical cores, so `cpu=1` equals two vCPUs, and it rejects requests above a maximum that it enforces at creation.

Modal may evict a Sandbox that exceeds its memory request if the host runs out of memory. Set the request to cover the memory your workload needs to retain.

Modal's GPU Sandboxes run on the gVisor runtime only and are subject to [preemption](https://modal.com/docs/guide/preemption), unlike its CPU Sandboxes.

Both products can start several environments from one snapshot. Vercel also copies a sandbox with [`Sandbox.fork()`](https://vercel.com/docs/sandbox/sdk/javascript#sandboxfork), using its latest saved state and configuration except for Drive mounts. Specify those mounts when forking.

### Lifecycle

Vercel saves a persistent sandbox's filesystem when its session stops. Modal ends a Sandbox when its entrypoint finishes, a timeout expires, or your code calls `terminate()`. Root filesystem changes are discarded unless saved in a snapshot.

| Concern               | Vercel Sandbox                                                                                                                                          | Modal Sandboxes                                                                                                                                                                                                                                                                               |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Session end           | Default 5 minutes. Extend to 45 minutes on Hobby or 24 hours on Pro and Enterprise with `sandbox.extendTimeout()`.                                      | Default 5 minutes. Set `timeout` at creation for up to 24 hours, with an optional `idle_timeout`.                                                                                                                                                                                             |
| State kept by default | Filesystem and configuration [snapshotted on stop](https://vercel.com/docs/sandbox/concepts/persistent-sandboxes)                                       | None unless saved in a snapshot, [exit snapshot](https://modal.com/docs/guide/sandbox-exit-snapshots), or Volume                                                                                                                                                                              |
| Running processes     | Not restored on resume                                                                                                                                  | Filesystem and directory snapshots do not restore processes. Alpha memory snapshots can restore entrypoint processes, with restrictions on `exec`.                                                                                                                                            |
| How it resumes        | An SDK operation that requires a running VM, such as `runCommand()`, starts a new session from the latest snapshot                                      | Create another Sandbox from a saved filesystem-snapshot Image                                                                                                                                                                                                                                 |
| Snapshots             | Automatic on stop, or manual with `snapshot()`, which also stops the session. Default expiry is 30 days after last use; customize it or disable expiry. | Manual, or automatic on exit when you opt in to exit snapshots, which are in beta. [Filesystem and directory snapshots](https://modal.com/docs/guide/sandbox-snapshots) expire 30 days after creation by default, and you can change or remove the TTL. Memory snapshots expire after 7 days. |
| Other persistence     | [Drives](https://vercel.com/docs/sandbox/concepts/drives) mounted as directories, up to four per sandbox                                                | [Volumes and Cloud Bucket Mounts](https://modal.com/docs/guide/sandbox-files)                                                                                                                                                                                                                 |
| Disposable mode       | `persistent: false` discards files on stop                                                                                                              | The default behavior                                                                                                                                                                                                                                                                          |

A Modal filesystem snapshot covers the Sandbox's root filesystem only, so mounted Volumes aren't included. To carry state across Modal Sandboxes, snapshot from your controller before the Sandbox terminates and store the returned Image ID against a session or user ID. Modal has no API to list the snapshots you've created, so your application tracks those IDs to restore or delete them.

Modal's [exit snapshots](https://modal.com/docs/guide/sandbox-exit-snapshots), in beta, save the root filesystem after termination, entrypoint completion, timeouts, or an out-of-memory kill. Enable them at creation with `experimental_options={"enable_exit_snapshot": True}`.

After exit, retrieve the Image with `sb._experimental_get_exit_snapshot()` and use it to create another Sandbox. Exit snapshots remain for 30 days and are not guaranteed after hardware failure or GPU preemption.

Modal's `idle_timeout` treats a Sandbox as active while an `exec` command runs, its stdin receives writes, or one of its tunnels holds an open TCP connection. For work that outlasts 24 hours, Modal recommends snapshotting the filesystem and restoring it in a new Sandbox.

On Vercel, each resume starts a new session timeout. The same persistent sandbox can span repeated sessions while its saved snapshot remains available. Requests to a stopped sandbox's public URL return [HTTP 410](https://vercel.com/docs/errors/SANDBOX_STOPPED). Resume it with an operation such as `runCommand()` before sending traffic.

### Networking and security

Both products allow outbound access to the public internet by default and support policies that restrict it. A default Modal Sandbox accepts no inbound connections and can't access other resources in your Modal workspace. A Vercel sandbox exposes only the ports you list at creation.

| Concern              | Vercel Sandbox                                                                                                                     | Modal Sandboxes                                                                                                                                                                                                                             |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Default egress       | Allow all                                                                                                                          | Allow all public IP addresses                                                                                                                                                                                                               |
| Egress controls      | [Allow all, deny all, or domain/CIDR allow lists](https://vercel.com/docs/sandbox/concepts/firewall); denied CIDRs take precedence | [`block_network`](https://modal.com/docs/guide/sandbox-networking)[, a CIDR allowlist, or a domain allowlist](https://modal.com/docs/guide/sandbox-networking). The domain allowlist is in beta and matches TLS traffic on port 443 by SNI. |
| Runtime updates      | Replace the policy without restarting the session                                                                                  | Experimental API in alpha. Each allowlist type must be set at creation, and a Sandbox created with `block_network` can't be updated.                                                                                                        |
| Credential injection | Brokering rules on allowed domains that match path, method, query parameters, and headers                                          | [Outbound Policy](https://modal.com/docs/guide/sandbox-secret-injection), in beta, replaces headers by destination domain. It can't be combined with `block_network` or either allowlist.                                                   |
| HTTPS inspection     | Per-sandbox CA for domains with request-transforming rules                                                                         | Per-Sandbox CA for domains that match an Outbound Policy rule. Allowlists don't decrypt TLS.                                                                                                                                                |
| Inbound access       | Up to 15 ports, each with a public URL that anyone with the URL can reach                                                          | No inbound access by default. Configure tunnels or authenticated HTTP/WebSocket access with Connect Tokens.                                                                                                                                 |
| Compliance           | SOC 2 Type II certified infrastructure; snapshots encrypted at rest                                                                | [SOC 2 Type II](https://modal.com/docs/guide/security); encrypted stored data. Enterprise HIPAA support has product-specific exclusions.                                                                                                    |

Credentials stored in a sandbox's environment are visible to code running there. Both products can add secrets after requests leave the sandbox. Vercel uses brokering rules; Modal uses an Outbound Policy or a Sidecar proxy.

On Modal, DNS traffic stays open unless you block all outbound traffic. Ordinary domain allowlists on both products match the TLS hostname without checking the HTTP `Host` header. If the destination accepts a mismatch, a request can reach another host behind the same endpoint through [domain fronting](https://modal.com/docs/guide/sandbox-networking#how-domain-filtering-works).

Vercel can enforce the host with an unconditional [header-transform rule](https://vercel.com/docs/sandbox/concepts/firewall#http-and-https) or a proxy that checks requests. Modal suggests a Sidecar proxy for that protection.

Code inside the sandbox can still make requests that those controls authorize. Restrict destinations and permissions to the task on either platform.

### Regions and placement

Vercel Sandbox runs in [19 regions](https://vercel.com/docs/sandbox/concepts/regions), with selection per sandbox or as a project default. Its default is `iad1` in Washington, D.C. Pro and Enterprise teams can configure failover regions, excluding Pro trials. Snapshots are saved in the region where the session runs.

Modal schedules a Sandbox anywhere in its multi-cloud pool unless you pass `region` to `Sandbox.create()`. [Region selection](https://modal.com/docs/guide/region-selection) accepts broad regions such as `us`, `eu`, and `ap`, or narrow regions such as `us-west`. Pinning is strict, so a pinned Sandbox never moves elsewhere when the region runs out of capacity.

Compute placement doesn't determine where Modal stores data. Modal keeps [snapshots, Images, Volumes, and logs](https://modal.com/docs/guide/data-residency) in the United States regardless of the Sandbox's region, and its lifecycle requests such as create and terminate route through a control plane in `us-east`. For storage in a region you choose, Modal recommends mounting your own bucket with a Cloud Bucket Mount.

### Core SDK calls

Install and authenticate before running either sample:

For Vercel, [set up the project below](#get-started-with-vercel-sandbox) to install the SDK and load its OIDC token.

For Modal, use Node.js 22 or later and install the [`modal`](https://modal.com/docs/sdk/js/latest) [package](https://modal.com/docs/sdk/js/latest):

**pnpm**

```bash
pnpm add modal
```

**yarn**

```bash
yarn add modal
```

**npm**

```bash
npm i modal
```

**bun**

```bash
bun add modal
```

Create an API token in your Modal workspace settings. Set `MODAL_TOKEN_ID` to its ID and `MODAL_TOKEN_SECRET` to its secret.

Save the selected script under its filename. It executes a command, writes and reads a file, then stops the sandbox. Plan allowances or charges apply.

**Vercel Sandbox**

```javascript
import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create();

try {
  const result = await sandbox.runCommand('node', ['--version']);
  console.log(await result.stdout());

  await sandbox.writeFiles([
    { path: 'hello.txt', content: Buffer.from('hi') },
  ]);
  const file = await sandbox.readFileToBuffer({ path: 'hello.txt' });
  console.log(file?.toString());
} finally {
  await sandbox.stop();
}
```

**Modal Sandboxes**

```javascript
import { ModalClient } from "modal";

const modal = new ModalClient();
const app = await modal.apps.fromName("my-app", { createIfMissing: true });
const image = modal.images.fromRegistry("python:3.13-slim");

const sb = await modal.sandboxes.create(app, image);

try {
  const p = await sb.exec(["python", "--version"]);
  console.log(await p.stdout.readText());

  await sb.filesystem.writeText("hi", "/tmp/hello.txt");
  console.log(await sb.filesystem.readText("/tmp/hello.txt"));
} finally {
  await sb.terminate();
}
```

By default, `sandbox.stop()` ends the Vercel session and snapshots its files. The next `runCommand()` resumes the same sandbox from that snapshot.

In the Modal sample, `sb.terminate()` ends the Sandbox and discards its filesystem. To keep the files, call `sb.snapshotFilesystem()` before terminating and pass the returned Image to a later `modal.sandboxes.create()` call.

Every Modal Sandbox belongs to an [App](https://modal.com/docs/guide/apps), which the sample looks up or creates by name. Modal's `exec()` takes the command as an argument array, and Modal's own examples wrap shell syntax such as loops and pipes in `bash -c`.

### Python SDK calls

Vercel's `vercel-sandbox` requires Python 3.11 or later and supports sync and async APIs. Modal's `modal` package is its most complete SDK, with synchronous methods and `.aio` asynchronous variants.

The Vercel excerpt uses its asynchronous interface; the Modal excerpt uses the synchronous one. Follow the [Vercel Python SDK reference](https://vercel.com/docs/sandbox/sdk/python) or the [Modal Sandboxes guide](https://modal.com/docs/guide/sandboxes) to install and authenticate the client.

**Vercel Sandbox**

```python
import asyncio

from vercel import sandbox


async def main() -> None:
    sbx = await sandbox.create_sandbox()

    try:
        result = await sbx.run_command(
            "python", ["--version"], capture_output=True, check=True
        )
        print(result.stdout.decode(), end="")

        await sbx.fs.write_text("hello.txt", "hi")
        print(await sbx.fs.read_text("hello.txt"))
    finally:
        await sbx.stop()


asyncio.run(main())
```

**Modal Sandboxes**

```python
import modal

app = modal.App.lookup("my-app", create_if_missing=True)
sb = modal.Sandbox.create(app=app)

try:
    process = sb.exec("python", "--version")
    print(process.stdout.read(), end="")

    sb.filesystem.write_text("hi", "/tmp/hello.txt")
    print(sb.filesystem.read_text("/tmp/hello.txt"))
finally:
    sb.terminate()
```

To build a code interpreter on either product, write the model's script to a file and run it, or pass it to `python -c`. On Vercel Sandbox, use `sbx.fs.write_text()` and `run_command()`. On Modal, use `sb.filesystem.write_text()` and `sb.exec()`.

## Where Vercel Sandbox goes deeper

### A dedicated kernel and root access in every sandbox

Each Vercel sandbox has its own kernel, so a process can run with `sudo` while the microVM boundary isolates it from other sandboxes and the host. Supported [system-level operations](https://vercel.com/docs/sandbox/concepts/security) include Docker, VPN access to private networks, and FUSE mounts. In the SDK, pass `sudo: true` to `runCommand()`.

Modal's gVisor runtime doesn't give the Sandbox its own Linux kernel. For Docker, FUSE filesystems, or nested cgroups, Modal directs you to `runtime="vm"`, which you set when you create the Sandbox. Modal's GPU Sandboxes can't use the VM runtime, and nested virtualization requires its Enterprise plan.

### Persistent workspaces by default

Vercel sandboxes save their filesystem automatically unless you set `persistent: false`. Snapshot expiration can be set to `0` for indefinite retention, and one snapshot can [seed multiple sandboxes](https://vercel.com/docs/sandbox/concepts/snapshots), subject to your plan's quotas.

Each persistent Vercel sandbox is a named entity that survives across sessions, so your application reconnects by name instead of tracking snapshot IDs.

For a filesystem-snapshot restore on Modal, save the Image ID or retrieve the exit snapshot through the original Sandbox ID, then pass the Image to `Sandbox.create()`. This creates a new Sandbox with a new ID. The name of a running Sandbox is unique within its App and becomes reusable after termination; reusing that name does not restore files.

### Drives

[Vercel Drives](https://vercel.com/docs/sandbox/concepts/drives) keep working files separate from the sandbox's starting environment. Mount up to four drives for workspaces or dependency caches and reuse their files in later sandboxes. The sandbox's main region must match the Drive's region. Each drive allows one writable mount, plus read-only snapshots for concurrent readers.

Modal's counterparts are [Volumes and Cloud Bucket Mounts](https://modal.com/docs/guide/sandbox-files). A Volume persists changes through background commits every few seconds and a final commit when the Sandbox terminates. A Sandbox calls `reload_volumes()` to see changes made after it mounted the Volume. Volume data is stored in the United States, while a Cloud Bucket Mount keeps files in your own bucket.

### Declarative egress firewall and credentials brokering

The Vercel [firewall](https://vercel.com/docs/sandbox/concepts/firewall) controls outbound access through modes and allow lists. Brokering rules inject credentials into requests that match a path, method, query, or header. Add a direct-response rule to block other requests to an allowed domain.

Policies can change while code runs, so an agent can begin with egress denied and receive access to selected APIs as its task progresses.

Modal's [Outbound Policy](https://modal.com/docs/guide/sandbox-secret-injection) injects headers by destination domain and can't be combined with `block_network` or either allowlist. Modal's built-in controls therefore don't pair credential injection with an egress allowlist on the same Sandbox. The Outbound Policy is in beta, supports HTTP/1.1 only, and requires named Secrets. To filter by path or method on Modal, run your own proxy in a [Sidecar](https://modal.com/docs/guide/sandbox-sidecars).

For private dependencies, [managed npm credentials](https://vercel.com/docs/sandbox/concepts/credentials) reuse your team's registry configuration, including GitHub Packages and JFrog Artifactory. Set `credentials: { npm: true }` at creation to let the firewall authenticate package downloads without storing tokens in the sandbox's `.npmrc`.

This supports package installation only. Configure the registry credentials as team Shared Environment Variables in Development or Preview, and allow the registry hosts in the network policy.

### Regional storage for snapshots and Drives

Vercel stores snapshots in the region where the session runs. Each Drive keeps data in its creation region. Configured failover can run sessions elsewhere and read those files across regions; new snapshots stay in the failover region. Choose main and failover regions that meet your residency requirements.

Modal stores snapshots in the United States regardless of compute region. If your data must stay elsewhere, take base snapshots before adding that data.

### Private network access

Attach a sandbox to a [Secure Compute network](https://vercel.com/docs/sandbox/concepts/secure-compute) to reach private APIs or databases in your AWS VPC over VPC peering. Public internet traffic leaves through the network's static IPs, which you can allowlist at external services. Secure Compute is an [additional Enterprise purchase](https://vercel.com/docs/networking/secure-compute).

Modal offers [Proxies](https://modal.com/docs/guide/proxy-ips), in beta, on its Team and Enterprise plans. A Modal Proxy sends a Sandbox's traffic over WireGuard to exit nodes with up to five static IPs, which you allowlist in your own network firewall.

### Separate users for collaborating agents

[Create a Linux user for each agent](https://vercel.com/docs/sandbox/concepts/multi-agent) to give agents separate home directories and file permissions within one sandbox. The JavaScript and Python SDKs support users, and the JavaScript SDK adds groups with shared directories. Your application keeps access to every agent's files. The users share one microVM, so run agents in separate sandboxes when each needs its own kernel.

Modal ignores an image's `USER` instruction and starts containers as root. You can reduce process privileges with `setuid` or Python's subprocess `user` parameter. Use Sidecars when agents need separate container isolation.

### Agent frameworks and hosted agent APIs

eve's [`eve/sandbox/vercel`](https://vercel.com/docs/frameworks/agents/eve) provider supports Vercel Sandbox and Drive mounts. [Mastra](https://vercel.com/docs/sandbox/ecosystem/mastra) and [Flue](https://vercel.com/docs/sandbox/ecosystem/flue) also integrate with Vercel Sandbox. The [ecosystem](https://vercel.com/docs/sandbox/ecosystem) includes LangChain, TanStack AI, and the OpenAI and Anthropic SDKs.

Vercel Sandbox integrates with [Gemini API Managed Agents](https://vercel.com/docs/sandbox/ecosystem/gemini-api) and the [OpenAI Agents API](https://vercel.com/docs/sandbox/ecosystem/openai-agents-api). Modal supports [Claude Managed Agents](https://modal.com/blog/introducing-claude-managed-agents-with-modal-sandboxes) and has an [OpenAI Agents API provider guide](https://developers.openai.com/api/docs/guides/agents-api/environments/providers/modal). Its [OpenAI Agents SDK extension](https://modal.com/blog/building-with-modal-and-the-openai-agent-sdk) connects agents to Sandboxes.

### Coding agents in a coding sandbox

Coding agents can run inside Vercel Sandbox or offload work from your machine:

- Run the agent inside a sandbox. The [Sandbox CLI](https://vercel.com/docs/sandbox/sdk/cli) starts a supported agent, such as OpenCode, Claude Code, or Codex, in a sandbox, and you use its interface from your local terminal.
  
- Keep the agent local and offload heavy work. The agent edits on your machine and uses Vercel Sandbox as a remote coding sandbox. The [offload-to-sandbox](https://skills.sh/vercel/vercel-plugin/offload-to-sandbox) skill, included in the [Vercel plugin](https://vercel.com/docs/agent-resources/vercel-plugin), moves heavy builds, long test suites, and parallel tasks into their own sandboxes, then collects the results and cleans up.
  

Hosted coding agents can run in Vercel Sandbox too. The [Cursor integration](https://vercel.com/docs/sandbox/ecosystem/cursor) uses Enterprise Team Pools and gives each Cloud Agents request its own microVM.

The [Devin integration](https://vercel.com/docs/sandbox/ecosystem/devin) runs Outposts sessions in sandbox microVMs. It requires Outposts access and a Vercel Pro or Enterprise team.

Modal provides SDK examples for running [Claude Code](https://modal.com/docs/examples/sandbox_agent) in a Sandbox, hosting [Cursor Cloud Agents](https://modal.com/docs/examples/cursor), and building a [coding agent with LangGraph](https://modal.com/docs/examples/agent).

## Where Modal goes deeper

### GPUs inside the sandbox

Pass `gpu` to `Sandbox.create()` to attach an Nvidia GPU from T4 through B300. GPU Sandboxes require gVisor and don't support memory snapshots. Because they can be preempted, design GPU work to handle interruption.

Vercel Sandbox provisions CPU and memory only. An agent in a Vercel sandbox calls hosted models over the network, for example through [AI Gateway](https://vercel.com/docs/ai-gateway).

### CPU and memory that burst above the request

Modal Sandboxes request 0.125 cores and 128 MiB by default and use more when the host has spare capacity, up to a default CPU limit of 16 cores above the request. This lets a workload use additional CPU and memory without a resize.

Pass `cpu` and `memory` as request and limit pairs to guarantee a floor and to cap what an agent can consume. Each Modal Sandbox also has a 512 GiB disk quota, compared with 64 GB of ephemeral NVMe on Vercel.

Vercel provisions the vCPUs and memory you select for the whole session. Active CPU billing excludes time spent waiting on I/O, while provisioned memory is metered throughout the session.

### Directory and memory snapshots

Modal offers three [snapshot types](https://modal.com/docs/guide/sandbox-snapshots). Filesystem snapshots capture the root filesystem as an Image. Directory snapshots capture one directory and mount into a Sandbox that's already running with `mount_image()`, which lets a warm pool attach a user's project after startup.

Memory snapshots, in alpha, preserve memory and the filesystem, including entrypoint processes. Finish active `exec` commands before taking one. Background processes launched through `exec` are not restored correctly.

Taking a memory snapshot terminates the Sandbox. The snapshot expires after seven days and requires the same instance type for restoration, without GPUs or region pinning. Vercel snapshots save files, so restart processes on resume.

### Sidecar containers

[Sandbox Sidecars](https://modal.com/docs/guide/sandbox-sidecars), in beta, are separate containers that run beside a Modal Sandbox's main container on the same host. Each Sidecar has its own image and outbound network policy, with the same isolation boundary as a separate Sandbox.

Use a Sidecar to keep proxy credentials outside the agent's container, separate an agent from its tool execution, or run a database beside the workload. Each Modal Sandbox supports up to 250 Sidecars sharing its CPU and memory.

### Authenticated inbound access

A Modal Sandbox accepts no inbound connections until you add them. [Connect Tokens](https://modal.com/docs/guide/sandbox-networking#connecting-to-sandboxes-with-http-and-websockets) give authenticated HTTP and WebSocket access to a port and pass your metadata to the server in an `X-Verified-User-Data` header. The `inbound_cidr_allowlist` parameter restricts which source IPs can reach encrypted tunnels and Connect Tokens.

Modal tunnels also expose raw TCP and HTTP/2 ports. Custom domains are in beta on Team and Enterprise plans and require manual setup with Modal. Vercel Sandbox port URLs are public, so your server must authenticate callers.

### Idle timeouts and readiness probes

`idle_timeout` terminates a Modal Sandbox after a period with no running commands, stdin writes, or open tunnel connections, in addition to the `timeout` ceiling. [Readiness probes](https://modal.com/docs/guide/sandboxes#readiness-probes) check a TCP port or run a command until startup work finishes, and `wait_until_ready()` blocks until the probe succeeds.

On Vercel, your application sets and extends the session timeout. The `onResume` hook can restart services after a stopped session resumes. Check that those services are ready before sending traffic.

### One platform for sandboxes, GPUs, and Python functions

Modal Sandboxes share Images, Volumes, and Secrets with [Modal Functions](https://modal.com/docs/guide/apps), so one workspace can run model inference, batch jobs, and sandboxes. Modal also ships a [Go SDK](https://modal.com/docs/sdk/go/latest) alongside its Python and JavaScript SDKs.

## Estimate usage for your workload

Measure a representative task's CPU use, memory, run time, storage, and transfer before estimating cost. Use the current rates and allowances for your plan and region from [Vercel Sandbox pricing](https://vercel.com/docs/sandbox/pricing) and [Modal pricing](https://modal.com/pricing).

## Choose by workload requirements

Compare these AI agent sandboxes against your workload requirements:

| Requirement                                                                   | Product fit                | Reason                                                                                 |
| ----------------------------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------- |
| Automatic file persistence and resume by default                              | Vercel Sandbox             | Snapshot on stop; an operation such as `runCommand()` resumes the same sandbox         |
| Separate kernel for each sandbox                                              | Both, with different setup | Vercel uses Firecracker for every sandbox. On Modal, explicitly select the VM runtime. |
| Credentials restricted by request path or method, behind an egress allow list | Vercel Sandbox             | Brokering rules on allowed domains that can change at runtime                          |
| Regional storage for snapshots and working files                              | Vercel Sandbox             | Choose among 19 regions and configure failover for the same residency requirements.    |
| Attach a sandbox to a Secure Compute network                                  | Vercel Sandbox             | Enterprise network with AWS VPC peering and static egress IPs                          |
| 10,000 concurrent sandboxes on a self-serve plan                              | Vercel Sandbox             | Pro and Enterprise quota; Modal's Team plan allows 5,000 containers                    |
| Start a coding agent in a sandbox from your terminal                          | Vercel Sandbox             | Sandbox CLI support for agents such as OpenCode, Claude Code, and Codex                |
| GPUs inside the sandbox                                                       | Modal                      | `gpu` on `Sandbox.create()` with the gVisor runtime                                    |
| More than 64 GB of local disk                                                 | Modal                      | 512 GiB disk quota for each Sandbox                                                    |
| Authenticated inbound requests and source IP restrictions                     | Modal                      | Connect Tokens and `inbound_cidr_allowlist`                                            |
| A proxy, database, or agent harness in its own container beside the workload  | Modal                      | Sidecars, in beta, with their own image and network policy                             |
| Sandboxes beside GPU inference and Python functions                           | Modal                      | Sandboxes share Images, Volumes, and Secrets with Modal Functions                      |

Both products run generated code behind an isolation boundary with egress controls. The choice usually comes down to whether your agents need managed persistence and request-level network policy, or GPUs and elastic resources on the platform that also serves your models.

## Get started with Vercel Sandbox

Before you begin, make sure you have a [Vercel account](https://vercel.com/signup), the [Vercel CLI](https://vercel.com/docs/cli), and Node.js 22 or later. Sandbox is available on Hobby within the included usage.

Link this directory to the Vercel project that will own your sandboxes:

```bash
vercel link
```

Pull the project's environment variables into `.env.local`, including its development OIDC token. The token expires after 12 hours; repeat this command to refresh it.

```bash
vercel env pull
```

Install the SDK:

**pnpm**

```bash
pnpm i @vercel/sandbox
```

**npm**

```bash
npm i @vercel/sandbox
```

**yarn**

```bash
yarn add @vercel/sandbox
```

**bun**

```bash
bun add @vercel/sandbox
```

Save the [Vercel sample](#core-sdk-calls) as `sandbox.mjs` in your linked project directory.

Each run creates a persistent sandbox and uses your plan's allowances or billing. For a disposable run without snapshot storage, pass `persistent: false` to `Sandbox.create()`.

Run the script with the environment file loaded:

```bash
node --env-file=.env.local sandbox.mjs
```

The script prints the sandbox's Node.js version and `hi`, then stops the session. With default persistence, its files remain in a saved snapshot.

## Start from an eve template

The [eve with Vercel Drives template](https://vercel.com/templates/eve/eve-vercel-drives-starter) connects an agent in Slack or a terminal to shared team files. Each session reads a Drive snapshot mounted at `/drive`.

The `save_to_drive` tool opens a separate, short-lived sandbox with write access. This keeps ordinary sessions read-only and gives updates a dedicated write path.

## Next steps

- Configure [session timeouts and persistent files](https://vercel.com/docs/sandbox/concepts/persistent-sandboxes)
  
- Restrict egress and broker credentials with the [Sandbox firewall](https://vercel.com/docs/sandbox/concepts/firewall)
  
- Expose a dev server with [public ports](https://vercel.com/docs/sandbox/examples/expose-a-port)
  
- Authenticate from [outside Vercel with an access token](https://vercel.com/docs/sandbox/concepts/authentication)
  
- Estimate your bill with [Sandbox pricing and quotas](https://vercel.com/docs/sandbox/pricing)
  
- Compare Vercel Sandbox with [E2B](https://vercel.com/kb/guide/vercel-sandbox-vs-e2b), [Cloudflare Sandbox](https://vercel.com/kb/guide/vercel-sandbox-vs-cloudflare-sandbox), and [Upstash Box](https://vercel.com/kb/guide/vercel-sandbox-vs-upstash-box)
  

## Frequently asked questions

### Is a Modal Sandbox a microVM like Vercel Sandbox?

Modal offers both gVisor and a VM runtime. Set `runtime="vm"` for a separate Linux kernel on KVM; Modal chooses the runtime when you omit it. Vercel Sandbox uses a Firecracker microVM with its own kernel for every sandbox.

### Can I run Docker in Vercel Sandbox and Modal?

Yes. Vercel Sandbox runs Docker with `sudo` inside its microVM. On Modal, select `runtime="vm"`, start `dockerd` as the entrypoint, then use `exec` to run containers.

Containers inside Vercel Sandbox must [trust its proxy CA certificate](https://vercel.com/docs/sandbox/concepts/security#trust-the-proxy-ca-in-containers) when calling domains with request-modifying firewall rules, such as credential injection.

### What happens to my files when a Vercel or Modal sandbox stops?

Vercel saves a persistent sandbox's filesystem when its session ends. The next SDK call that needs the VM restores those files. On Modal, files survive through a snapshot, an exit snapshot enabled at creation, a Volume, or a Cloud Bucket Mount. Other root filesystem changes are discarded on termination.

Vercel does not restore processes. Modal's alpha memory snapshots can restore entrypoint processes, but not background processes launched through `exec`.

### Does a Modal Sandbox have internet access by default?

Yes, for outbound traffic. A default Modal Sandbox can connect to any public IP address and accepts no inbound connections. Vercel Sandbox also starts with the `allow-all` firewall mode, and you can switch a sandbox to `deny-all` or a user-defined allow list while it runs.

### Can I use a GPU in Vercel Sandbox or Modal?

Modal attaches Nvidia GPUs to Sandboxes on its gVisor runtime, and those Sandboxes are subject to preemption. Vercel Sandbox provisions vCPUs and memory without a GPU option, so agents in Vercel Sandbox call hosted models through an API such as AI Gateway.

### How long can a Vercel or Modal sandbox run?

A Vercel session runs for up to 45 minutes on Hobby or 24 hours on Pro and Enterprise, and a persistent sandbox can span many sessions. A Modal Sandbox runs for up to 24 hours, set with `timeout` at creation. To continue past that limit on Modal, snapshot the filesystem and start a new Sandbox from the snapshot.

### Can I run Python in Vercel Sandbox and Modal?

Yes. Vercel's default universal image includes Python 3.14, and the `vercel-sandbox` SDK lets Python 3.11+ apps create and control sandboxes. Modal runs any Image you supply, including Python images, and its Python SDK covers more of the platform than its JavaScript and Go SDKs.

### Can I use Modal Sandboxes from TypeScript?

Yes. The `modal` npm package runs on Node.js 22+, Deno, and Bun. Modal's JavaScript and Go SDKs are in beta. Vercel provides the `@vercel/sandbox` TypeScript SDK and sync and async Python APIs.

### Can I use either product as an AI code interpreter?

Yes. Both can sandbox AI-generated code for tasks such as data analysis. Use Vercel's [SDKs](https://vercel.com/docs/sandbox#using-vercel-sandbox) from your backend, or Modal's SDKs with an API token. Limit each agent sandbox to the files, credentials, and network destinations its task needs.

## Related Resources

- [Vercel Sandbox vs Upstash Box](/kb/guide/vercel-sandbox-vs-upstash-box): Compare Vercel Sandbox and Upstash Box as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment regions.
- [Vercel Sandbox vs Cloudflare Sandbox](/kb/guide/vercel-sandbox-vs-cloudflare-sandbox): Compare Vercel Sandbox and Cloudflare Sandbox as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment options.

## More Vercel Sandbox guides

- [Vercel Sandbox vs Upstash Box](/kb/guide/vercel-sandbox-vs-upstash-box): Compare Vercel Sandbox and Upstash Box as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment regions.
- [Vercel Sandbox vs Cloudflare Sandbox](/kb/guide/vercel-sandbox-vs-cloudflare-sandbox): Compare Vercel Sandbox and Cloudflare Sandbox as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and deployment options.
- [Add Python code execution to a TypeScript AI agent with Vercel Sandbox](/kb/guide/python-ai-sdk-vercel-sandbox): Add an \`executeCode\` tool to your TypeScript AI SDK agent with the \`ai-sdk-tool-code-execution\` package to run Python 3.13 inside an isolated Vercel Sandbox.

## Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

- [Agent stack](/kb/architecture/agents): Build and operate agents with models, tools, and durable workflows.
- [Web applications](/kb/architecture/web): Choose rendering, data, authentication, and caching approaches.
- [Backends](/kb/architecture/backends): Choose a runtime, connect services, and run background work.

[Browse all stacks](/kb/architecture)

## Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

[Browse the prompt library](/kb/prompts) · [Read the Markdown index](/kb/prompts.md)

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```
