---
title: Vercel Sandbox vs Railway Sandboxes
description: Compare Vercel Sandbox and Railway Sandboxes as AI agent sandboxes, including isolation, persistence, network controls, SDKs, regions, and pricing.
keywords: ["Vercel Sandbox","Railway Sandboxes","AI agent sandbox","untrusted code execution","Firecracker microVM"]
url: "https://vercel.com/kb/guide/vercel-sandbox-vs-railway-sandboxes"
published: 2026-11-25
last_updated: 2026-11-25
authors: Ben Sabic
related_resources:
  - 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."
  - 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 vs Railway"
    url: "/kb/guide/vercel-vs-railway"
    description: "A detailed guide to Vercel vs Railway: serverless vs always-on containers, container images from a Dockerfile, framework-defined infrastructure, AI infrastructure, global CDN, security, and when to choose each platform for your project."
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-railway-sandboxes"
---

[Vercel Sandbox](https://vercel.com/docs/sandbox) and [Railway Sandboxes](https://docs.railway.com/sandboxes) are AI sandboxes for running generated code in Linux environments. Vercel uses a Firecracker microVM with its own kernel and saves its files by default when a session stops. Railway runs an isolated Linux VM inside a Railway environment and by default destroys it after an idle timeout.

Choose Vercel Sandbox for files that persist between sessions by default, egress rules with credential brokering, or a wider choice of regions. Choose Railway Sandboxes for a sandbox on the same private network as the services and databases you run on Railway, or for forking a running sandbox.

## How Vercel Sandbox and Railway Sandboxes compare

Railway Sandboxes is [generally available](https://railway.com/changelog/2026-09-18-railway-sandboxes) with a [beta SDK](https://github.com/railwayapp/railway-ts-sdk). Its separate [Cloud agents](https://docs.railway.com/cloud-agents) product runs persistent VMs that sleep when idle and wake on access.

### Compute and resources

Vercel Sandbox runs each environment in a [Firecracker microVM with its own kernel](https://vercel.com/docs/sandbox/concepts/security). Railway runs an [isolated Linux VM](https://docs.railway.com/sandboxes) but doesn't identify its hypervisor in the public reference. If your security review requires that detail, confirm Railway's architecture before choosing a provider.

| Concern                 | Vercel Sandbox                                                                                                                                                                                                           | Railway Sandboxes                                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Isolation               | Firecracker microVM with its own kernel                                                                                                                                                                                  | Isolated Linux VM; hypervisor not specified.                                                                                                                   |
| Base environment        | [Managed images](https://vercel.com/docs/sandbox/concepts/images) built on Ubuntu 26.04 (the default universal image has Node.js 24 and Python 3.14) or Arch Linux, or a custom OCI image from Vercel Container Registry | Ubuntu-based standard image with git, Node, and coding agents preinstalled. Custom bases come from templates or checkpoints.                                   |
| vCPUs                   | 1 or even numbers; default 2. Limits: 4 (Hobby), 8 (Pro), 32 (Enterprise).                                                                                                                                               | Fractions allowed. Defaults: 2 (Trial and Free), 4 (Hobby), 8 (Pro). Limits: 2 (Trial and Free), 8 (Hobby), 24 (Pro). Enterprise limits are set per agreement. |
| Memory                  | 2 GB per vCPU, up to 8 GB on Hobby, 16 GB on Pro, 64 GB on Enterprise                                                                                                                                                    | Set with `memoryGB`. Defaults: 2 GB (Trial and Free), 4 GB (Hobby), 8 GB (Pro). Limits: 2 GB (Trial and Free), 8 GB (Hobby), 24 GB (Pro).                      |
| Disk                    | 64 GB NVMe; SDK 3.0.0+ or custom image                                                                                                                                                                                   | Railway's docs don't state a disk size                                                                                                                         |
| Concurrent environments | Hobby: 10. Pro and Enterprise: 10,000.                                                                                                                                                                                   | Per Railway environment: 10 on Trial and Free, 50 on Hobby, 100 on Pro. Enterprise starts at 100 and can be raised on request.                                 |
| SDKs and tools          | TypeScript SDK, sync/async Python SDK, Sandbox CLI, Vercel CLI, and Vercel REST API                                                                                                                                      | TypeScript SDK, `railway sandbox` CLI, dashboard, and GraphQL API                                                                                              |
| Authentication          | Project-scoped Vercel OIDC token, or an access token with team and project IDs                                                                                                                                           | Project token in `RAILWAY_TOKEN`, scoped to one environment, or an account or workspace token in `RAILWAY_API_TOKEN` with `RAILWAY_ENVIRONMENT_ID`             |
| Plan                    | Hobby, Pro, and Enterprise                                                                                                                                                                                               | Every plan, including Free and the Trial                                                                                                                       |

Railway Pro allows up to 24 vCPUs and 24 GB, with independent `cpu` and `memoryGB` settings. Older Pro plan limits reach 32 vCPUs and 32 GB. Vercel provisions 2 GB of memory per vCPU and supports [Enterprise sizes](https://vercel.com/docs/sandbox/pricing#resource-limits) up to 32 vCPUs and 64 GB.

Vercel supports 10,000 concurrent sandboxes on Pro and Enterprise. Railway's Pro limit is 100 per environment, including failed sandboxes and temporary template-build sandboxes. Each counts until it is destroyed.

Vercel's 64 GB disk capacity requires Sandbox SDK 3.0.0+ or a custom image; deprecated runtimes receive 32 GB. Both products also let you create or branch many environments from one snapshot.

### Lifecycle

Vercel Sandbox limits each session's duration and saves the filesystem when a persistent session stops. Railway keeps a sandbox running until its idle timeout expires or you destroy it, and destroying it discards its filesystem.

| Concern               | Vercel Sandbox                                                                                                                              | Railway Sandboxes                                                                                                                                          |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Session end           | Default 5 minutes. Extend to 45 minutes on Hobby or 24 hours on Pro and Enterprise with `sandbox.extendTimeout()`.                          | Idle timeout: 30 minutes by default on Hobby and Pro, settable from 1 to 120 minutes. 5 minutes on Trial and Free, settable from 1 to 5 minutes.           |
| What keeps it running | The session timeout, which your code can extend                                                                                             | Commands and `sandbox.heartbeat()` reset the idle timer. A running `exec` command defers teardown.                                                         |
| State kept by default | [Filesystem and configuration snapshotted on stop](https://vercel.com/docs/sandbox/concepts/persistent-sandboxes)                           | None. Files survive only in a checkpoint or a fork you created first.                                                                                      |
| Running processes     | Not restored on resume                                                                                                                      | Not kept by a fork or a checkpoint                                                                                                                         |
| How it resumes        | An SDK operation that requires a running VM, such as `runCommand()`, starts a new session from the latest snapshot                          | Railway's docs describe no pause or resume. Create a new sandbox from a checkpoint by name.                                                                |
| Always on             | Not designed to run continuously                                                                                                            | `idleTimeoutMinutes: 0` disables the idle timeout on Hobby and Pro. Not available on Trial and Free.                                                       |
| Disposable mode       | `persistent: false` discards the filesystem when the session stops                                                                          | The default behavior                                                                                                                                       |
| Snapshots             | Automatic on stop, or manual with `snapshot()`. They expire 30 days after last use by default, and you can change or remove the expiration. | Manual with `sandbox.checkpoint(name)`. Checkpoints stay in the environment until you delete them, up to 10 on Trial and Free, 50 on Hobby, or 100 on Pro. |

Railway's docs state no maximum lifetime for a sandbox. Running `exec` commands, including detached ones, defer idle teardown. Background processes outside an active session don't, so call `sandbox.heartbeat()` when work continues without a command attached. On Hobby and Pro, a sandbox with the idle timeout disabled stays billable until you destroy it.

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 the sandbox and restart its server with `runCommand()` before sending traffic.

To compare startup, time each product from your application's region, from the start of creation through the [first command](https://vercel.com/docs/sandbox/sdk/javascript).

### Networking and security

Both products allow outbound internet access by default. Vercel Sandbox restricts it with a declarative firewall. Railway's docs describe no egress allow list or deny list for sandboxes. Its network control is the isolation mode, which decides whether a sandbox can reach the private network of its Railway environment.

| Concern              | Vercel Sandbox                                                                                                                              | Railway Sandboxes                                                                                                                                                                              |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Default egress       | Allow all                                                                                                                                   | Outbound internet access through a NAT gateway, in both network modes                                                                                                                          |
| Egress controls      | Allow all, deny all, or [domain/CIDR allow lists](https://vercel.com/docs/sandbox/concepts/firewall); denied CIDRs take precedence          | Railway's docs don't document an egress allow list, a deny list, or a way to turn off outbound access                                                                                          |
| Runtime updates      | Replace the policy without restarting the session                                                                                           | The network mode is set when you create or fork a sandbox                                                                                                                                      |
| Private network      | [Secure Compute](https://vercel.com/docs/sandbox/concepts/secure-compute) network with AWS VPC peering and static egress IPs, on Enterprise | `PRIVATE` mode joins the environment's private network. The default `ISOLATED` mode can't reach it.                                                                                            |
| Credential injection | Brokering rules on allowed domains that match path, method, query parameters, and headers                                                   | Environment variables set at creation, which can reference other Railway variables. Railway's docs don't document a way to keep a credential out of the sandbox.                               |
| Inbound access       | Up to 15 ports, each with a public URL that anyone with the URL can reach                                                                   | Up to 10 HTTPS domains, one per port, set at creation and only in `PRIVATE` mode, or SSH port forwarding. Railway's docs don't describe authentication on sandbox domains.                     |
| Compliance           | SOC 2 Type II certified infrastructure; snapshots encrypted at rest                                                                         | Railway's [SOC 2 Type II and SOC 3 certifications](https://docs.railway.com/enterprise/compliance) are stated for the platform. Confirm with Railway whether Sandboxes are in the audit scope. |

Credentials stored in a sandbox's environment are visible to code running there. Vercel's brokering rules add secrets after requests leave the sandbox, so the code never holds them. Railway passes secrets to a sandbox as environment variables, which its commands can read.

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

Railway's `PRIVATE` mode lets sandbox code reach the environment's services and databases, and lets them reach it. Public domains need the same mode, so a Railway sandbox with a public URL is on the private network too. Railway advises pointing networked sandboxes at a [development environment](https://docs.railway.com/guides/code-execution-sandboxes).

### Regions

Vercel Sandbox runs in [19 regions](https://vercel.com/docs/sandbox/concepts/regions), selected per sandbox or through a project default. The default is `iad1` in Washington, D.C. Pro and Enterprise teams can configure failover regions, except during a Pro trial.

Snapshots normally restore where they are available. Failover can load snapshots and Drives across regions and saves new snapshots in the failover region. Your main and failover regions must meet your data-residency requirements.

Railway Sandboxes run in four regions: US West, US East, EU West, and Southeast Asia. New sandboxes run in US West (`us-west2`) unless you pass `region` in the SDK or the API, and the CLI has no region flag. Forks, checkpoint restores, and templates run in the region where their data was captured or built.

Vercel's CPU, memory, and data-transfer rates vary by region.

### 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 Railway, install `railway` 3.17.0+ with Node.js 22+. Set `RAILWAY_TOKEN` in `.env.local` to a [project token](https://docs.railway.com/sandboxes/quickstart) for the target environment.
  

Save the Vercel script as `sandbox.mjs`. It runs a command, writes and reads a file, then stops the session.

Save the Railway sample as `railway-sandbox.mjs`. It runs the same steps in a billable sandbox, then deletes the sandbox and its files with `destroy()`.

**Vercel Sandbox**

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

const sandbox = await Sandbox.create();

try {
  const result = await sandbox.runCommand('node', ['--version']);
  if (result.exitCode !== 0) {
    throw new Error('Node version check failed');
  }
  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();
}
```

**Railway Sandboxes**

```javascript
import { Sandbox } from "railway";

// Reads a project token from RAILWAY_TOKEN.
const sandbox = await Sandbox.create();

try {
  const result = await sandbox.exec("node --version");
  if (result.exitCode !== 0) {
    throw new Error(result.stderr || 'Node version check failed');
  }
  console.log(result.stdout);

  await sandbox.files.write("/app/greeting.txt", "hello");
  const text = await sandbox.files.read("/app/greeting.txt");
  console.log(text);
} finally {
  await sandbox.destroy();
}
```

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

Railway's `sandbox.destroy()` deletes the sandbox and its files. Capture a checkpoint or create a fork first if you need to keep them. Both SDKs return a command exit code, which the examples check before continuing.

Run `railway-sandbox.mjs` with its environment file loaded:

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

Vercel's [Python SDK](https://vercel.com/docs/sandbox/sdk/python) supports Python 3.11+ with sync and async APIs. Railway's documented interfaces are its TypeScript SDK, CLI, and GraphQL API.

## Where Vercel Sandbox goes deeper

### Dedicated kernel and root access

Each 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()`.

### 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.

On Railway, call `sandbox.checkpoint(name)` before the sandbox is destroyed, then create a later sandbox from that checkpoint by name. Checkpoints stay until you delete them, and your plan sets how many each environment can hold.

### 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 reusable workspaces or dependency caches. Each drive supports one writer and concurrent readers through read-only snapshots.

The sandbox's main region must match the drive's region. Configured failover can load the drive from another region, as described in [Regions](#regions).

Railway's checkpoints and forks copy a sandbox's whole disk, so working files and the starting environment travel together.

### 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.

For private dependencies, [managed npm credentials](https://vercel.com/docs/sandbox/concepts/credentials) use registry credentials from your project or team, including GitHub Packages and JFrog Artifactory. Set `credentials: { npm: true }` at creation. The firewall authenticates package downloads without putting tokens in the sandbox's `.npmrc`.

Configure `NPM_TOKEN` or `NPM_RC` in the project environment used by the request. Vercel checks the project first, then team Shared Environment Variables in Development and Preview environments, in that order. Access tokens select the project's Development environment; OIDC tokens select their own environment.

Allow the registry hosts in the network policy. These credentials support package installation only, not publishing.

Railway's docs describe neither egress rules nor credential injection for sandboxes. Every Railway sandbox has outbound internet access, and secrets reach it as environment variables that its commands can read.

### Public port URLs

Expose up to 15 ports at creation or replace the port list later with `sandbox.update({ ports })`. Each port gets a public URL from [`sandbox.domain(port)`](https://vercel.com/docs/sandbox/examples/expose-a-port), without DNS or routing setup. Anyone with the URL can reach the server, so expose only services you intend to share.

Railway publishes up to 10 HTTPS domains per sandbox. They're set at creation, can't change afterward, and require `PRIVATE` mode, which also connects the sandbox to the environment's private network.

### 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).

Railway's `PRIVATE` mode is available on every plan and reaches the services in the sandbox's own Railway environment, which is a different target from a VPC you manage. See [private networking on Railway](#private-networking-with-your-railway-services).

### Custom images from Vercel Container Registry

Store dependencies and tools in a `linux/amd64` OCI image in [Vercel Container Registry](https://vercel.com/docs/sandbox/concepts/images). Sandboxes start from the image but don't run its `ENTRYPOINT` or `CMD`, so start processes with `runCommand()` after creation.

Railway builds a custom base from a template, an ordered list of `apt-get` packages and shell build steps that it caches, or from a checkpoint. Its docs don't describe starting a sandbox from a Docker or OCI image.

### 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.

### Agent framework integrations

eve includes a Vercel Sandbox provider in `eve/sandbox/vercel`. With that provider, sessions run code in Vercel Sandbox and can use supported [Vercel Drive mounts](https://vercel.com/kb/guide/vercel-drives-eve-agent). [Mastra](https://vercel.com/docs/sandbox/ecosystem/mastra) and [Flue](https://vercel.com/docs/sandbox/ecosystem/flue) also provide Vercel Sandbox integrations.

Explore [Vercel Sandbox integrations](https://vercel.com/docs/sandbox/ecosystem) for other frameworks.

### 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 use Vercel Sandbox too. [Cursor Cloud Agents](https://vercel.com/docs/sandbox/ecosystem/cursor) run through Team Pools on Cursor Enterprise. [Devin Outposts](https://vercel.com/docs/sandbox/ecosystem/devin) require Outposts access and administrator permissions, plus a Vercel Pro or Enterprise team.

Railway's default sandbox image includes [Claude Code, Codex, OpenCode, and Pi](https://docs.railway.com/guides/agents-in-sandboxes), and you pass each agent its own configuration or API key.

## Where Railway Sandboxes goes deeper

### Private networking with your Railway services

Each Railway sandbox is scoped to a Railway environment. Create or fork it with `networkIsolation: "PRIVATE"`, or `--private-network` in the CLI, and it joins that environment's [private network](https://docs.railway.com/sandboxes). The sandbox can then reach other services at their internal addresses, such as `postgres.railway.internal`, and they can reach it. Private networking is available on every Railway plan.

Sandbox variables can [reference other Railway variables](https://docs.railway.com/cli/sandbox), such as a database service's connection URL, in the `Service.VARIABLE` or `${{Service.VARIABLE}}` form. Railway resolves them when it creates the sandbox, and a reference to a service's internal address needs the private network.

Vercel's managed AWS VPC peering and static egress IPs use [Secure Compute](https://vercel.com/docs/sandbox/concepts/secure-compute), an additional Enterprise purchase. Sandboxes can also run a [VPN client](https://vercel.com/docs/sandbox/concepts/security) to reach a private network, subject to their firewall policy.

### Forks, checkpoints, and templates

Railway has three ways to [reuse a prepared filesystem](https://docs.railway.com/guides/agents-in-sandboxes):

- Forks copy a running sandbox's filesystem within its environment and region.
  
- Checkpoints save a named disk snapshot that survives the source sandbox. You can boot new sandboxes from it until you delete it.
  
- Templates are ordered lists of build steps that Railway builds once and caches.
  

These options preserve files without carrying over running processes or memory. Set the idle timeout, size, network mode, domains, and variables for each fork; it doesn't inherit those settings from the source.

Capturing a checkpoint leaves the source sandbox running. On Vercel, `snapshot()` stops the session it captures, and [`Sandbox.fork()`](https://vercel.com/docs/sandbox/sdk/javascript) starts from the source's saved snapshot without the unsaved changes of a running session.

### Durable command sessions

Commands started with Railway's `exec()` run on the sandbox independently of the client that started them. Each one gets a durable session name, so a client can stop streaming, disconnect, and reattach later from a different process. Railway keeps about the last 8 MiB of a session's output for reattaching. For a short command that needs no session, pass `ephemeral: true`.

The sandbox also outlives the process that created it and can be reattached by ID, which suits serverless and multi-step workflows. Commands started with `exec()` have no timeout unless you set `timeoutSec`.

In Vercel Sandbox, `runCommand()` with `detached: true` returns a command that [`sandbox.getCommand()`](https://vercel.com/docs/sandbox/sdk/javascript) retrieves by ID within the same session.

### SSH and port forwarding

The Railway dashboard opens an SSH session to a running sandbox in the browser. From a terminal, `railway sandbox ssh` connects with an SSH key on your Railway account, and [`railway sandbox forward`](https://docs.railway.com/cli/sandbox) maps a local port to a port in the sandbox, as in `railway sandbox forward 8080:3000`. Forwarding works in either network mode, so you can reach a server from your machine without publishing a domain. The CLI sends keepalive heartbeats while either session stays connected.

Vercel's [Sandbox CLI](https://vercel.com/docs/sandbox/sdk/cli) opens an interactive shell with `sandbox connect <name>`, and you reach servers through public port URLs.

### Lifetimes set by idle time

Railway sandboxes run until their idle timeout expires or you destroy them. Hobby and Pro workspaces can set the timeout from 1 to 120 minutes or disable it with `idleTimeoutMinutes: 0`. Trial and Free workspaces are limited to 1 to 5 minutes, and creating a sandbox with the timeout disabled fails on those plans.

Vercel instead limits each session to 45 minutes on Hobby or 24 hours on paid plans, and a persistent sandbox continues in a new session when it resumes.

### Sizes below one vCPU and above eight

Railway's `resources` option sets `cpu` and `memoryGB` at creation, and `cpu` accepts fractions such as `0.5`. Hobby allows up to 8 vCPUs and 8 GB, and Pro allows up to 24 vCPUs and 24 GB. Free and Trial sandboxes are limited to 2 vCPUs and 2 GB.

Vercel sizes start at 1 vCPU and 2 GB; more than 8 vCPUs requires Enterprise.

## Estimate costs for your workload

Estimate a representative task using [Vercel Sandbox pricing](https://vercel.com/docs/sandbox/pricing) and [Railway pricing](https://docs.railway.com/pricing/plans). Measure CPU use, memory, duration, storage, and transfer before applying your plan's rates and allowances.

## Choose by workload requirements

Compare the two agent sandboxes against your implementation requirements:

| Requirement                                                           | Product fit       | Reason                                                                         |
| --------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------ |
| Automatic file persistence between sessions                           | Vercel Sandbox    | Snapshot on stop; an operation such as `runCommand()` resumes the VM           |
| Egress rules and credential injection as configuration                | Vercel Sandbox    | Firewall modes and brokering rules that match path, method, query, and headers |
| Custom OCI starting image                                             | Vercel Sandbox    | Images from Vercel Container Registry                                          |
| More than four regions to choose from                                 | Vercel Sandbox    | 19 regions, chosen per sandbox or project                                      |
| Python SDK                                                            | Vercel Sandbox    | `vercel-sandbox`, with sync and async APIs                                     |
| Thousands of concurrent sandboxes                                     | Vercel Sandbox    | 10,000 on Pro and Enterprise                                                   |
| Managed AWS VPC peering and static egress IPs                         | Vercel Sandbox    | Enterprise network with AWS VPC peering and static egress IPs                  |
| Sandbox on the private network of your Railway services and databases | Railway Sandboxes | `PRIVATE` mode and Railway variable references, on every plan                  |
| Branch from a sandbox while it runs                                   | Railway Sandboxes | Forks and checkpoints copy a running sandbox's disk                            |
| Reattach to a running command from another process                    | Railway Sandboxes | Durable `exec` sessions with a session name                                    |
| SSH access and local port forwarding                                  | Railway Sandboxes | `railway sandbox ssh` and `railway sandbox forward`                            |
| Sandbox with no fixed session limit                                   | Railway Sandboxes | Idle timeout that Hobby and Pro workspaces can disable                         |
| More than 8 vCPUs without an Enterprise plan, or less than 1          | Railway Sandboxes | Up to 24 vCPUs and 24 GB on Pro, and fractional `cpu` values                   |

For an AI code interpreter, match the AI agent sandbox's isolation model to your threat model. Restrict the files, network destinations, and credentials that generated code can access.

## 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.

Connect a directory to a Vercel project, which handles [OIDC token authentication](https://vercel.com/docs/sandbox/concepts/authentication):

```bash
vercel link
```

Pull the project's environment variables into `.env.local`. The development token expires after 12 hours; refresh it with `vercel env pull` if it has expired.

```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 JavaScript sample from [Core SDK calls](#core-sdk-calls) as `sandbox.mjs` in the linked project directory. Each run creates a new persistent sandbox and counts toward your plan's allowances or billing. Set `persistent: false` in `Sandbox.create()` for a disposable run without snapshot storage.

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 to the Drive. Sessions can edit files in their own workspaces, but updates to the shared Drive go through this tool. Start a new session to see saved changes.

## Plan a Railway migration

Choosing a sandbox doesn't require moving the rest of your app. If you're also considering a platform move, [compare Vercel and Railway for application hosting](https://vercel.com/kb/guide/vercel-vs-railway), then [plan the migration service by service](https://vercel.com/kb/guide/migrate-railway-to-vercel). Include databases and stored files in that plan before switching traffic.

For a FastAPI, Flask, or Django backend, follow the [Python API migration steps](https://vercel.com/kb/guide/migrate-a-python-api-from-railway-to-vercel). Continuously running queue consumers have a separate [migration path to Vercel Daemons](https://vercel.com/kb/guide/migrate-railway-workers-to-vercel-daemons), which covers worker packaging, shutdown, and a gradual queue handoff.

## 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)
  
- [Boot from your own image with custom images](https://vercel.com/docs/sandbox/concepts/images)
  
- [Expose a dev server with public ports](https://vercel.com/docs/sandbox/examples/expose-a-port)
  
- [Estimate your bill with Sandbox pricing and quotas](https://vercel.com/docs/sandbox/pricing)
  
- Compare Vercel Sandbox with [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 Railway Sandboxes a microVM like Vercel Sandbox?

Vercel Sandbox uses a Firecracker microVM with its own kernel. Railway describes an isolated Linux VM but doesn't identify its hypervisor in the public reference. Confirm Railway's hypervisor if your security review requires it.

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

Vercel saves a persistent sandbox's files when its session ends and restores them when an SDK operation needs the VM again. Railway destroys the sandbox and its disk after the idle timeout or a `destroy()` call. Capture a checkpoint or fork it first to keep the files. Neither restores running processes.

### Can a Vercel or Railway sandbox reach my private database?

On Railway, create the sandbox with `PRIVATE` networking and pass in the database credentials, and it can connect to databases and services in the same Railway environment. On Vercel, attach the sandbox to a Secure Compute network, available on Enterprise, to reach a database in your AWS VPC over VPC peering. In both cases the code in the sandbox can use that access, so give it credentials for a development database where you can.

### Can I restrict outbound network access in Vercel Sandbox and Railway Sandboxes?

Vercel Sandbox starts in allow-all mode, and you can switch a sandbox to deny-all or a user-defined allow list while it runs. Railway routes every sandbox's outbound traffic through a NAT gateway, and its docs describe no allow list, deny list, or setting that turns outbound access off. Railway's `ISOLATED` and `PRIVATE` modes control access to the environment's private network only.

### Can I run Docker in Vercel Sandbox and Railway Sandboxes?

Both support running Docker inside a sandbox. In Vercel Sandbox, commands run with sudo can start Docker or another container engine inside the microVM. Containers must trust the sandbox's [proxy CA certificate](https://vercel.com/docs/sandbox/concepts/security#trust-the-proxy-ca-in-containers) when they call domains with request-modifying firewall rules.

Railway Sandboxes include the [Docker daemon and CLI](https://railway.com/changelog/2026-06-12-docker-in-sandboxes) for pulling images, building Dockerfiles, and running containers inside the VM.

## Related Resources

- [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.
- [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 vs Railway](/kb/guide/vercel-vs-railway): A detailed guide to Vercel vs Railway: serverless vs always-on containers, container images from a Dockerfile, framework-defined infrastructure, AI infrastructure, global CDN, security, and when to choose each platform for your project.

## More Vercel Sandbox guides

- [Vercel Sandbox vs Fly.io Sprites](/kb/guide/vercel-sandbox-vs-fly-io-sprites): Compare Vercel Sandbox and Fly.io Sprites as AI agent sandboxes, including isolation, persistence, network controls, SDKs, and idle behavior.
- [Vercel Sandbox vs CodeSandbox](/kb/guide/vercel-sandbox-vs-codesandbox): A detailed guide to Vercel Sandbox vs CodeSandbox: compute isolation, credential brokering, Active CPU billing, Docker support, persistent environments, and when to choose each product for your AI workloads.
- [Vercel Sandbox vs E2B](/kb/guide/vercel-sandbox-vs-e2b): A detailed guide to Vercel Sandbox vs E2B: compute lifecycle, security controls, code execution, pricing, and when to choose each sandbox for your AI agent workloads.

## 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>
```
