The safest way to run code you didn’t write
Run the agent’s code, the agent itself, or your own code
Every sandbox is the same isolated Firecracker microVM with its own filesystem and network. What you run inside it is up to you.
The agent’s code
Write the agent’s output to the sandbox filesystem and execute it there. You get the exit code and output back without running any of it on your own infrastructure.
// Run untrusted, agent-generated codeconst sandbox = await Sandbox.create();
const file = '/vercel/sandbox/code.mjs';await sandbox.writeFiles([{ path: file, content: Buffer.from(code) }]);
const run = await sandbox.runCommand({ cmd: 'node', args: [file] });console.log(run.exitCode, await run.stdout());
await sandbox.stop();The agent itself
Point a coding agent at a sandbox instead of your laptop. Its edits, package installs, and shell commands all stay inside the microVM.
- Install the CLI and log in.npm i -g sandboxsandbox login
- Start a sandbox and boot the agent.sandbox shclaude
The base image already includes claude, codex, and opencode, so there is nothing to install inside the sandbox. The agent walks you through its own login the first time you start it.
Your code
Builds, test suites, and migrations work the same way. One command gets you a clean machine, so nothing depends on what is installed on your laptop.
- Install the CLI and log in.npm i -g sandboxsandbox login
- Run a command.# One command creates a sandbox, runs the code, and hands back the outputsandbox run -- node -e "console.log('Hello from Vercel Sandbox')"
Vercel Sandbox
Vercel Sandbox
Vercel Sandbox
Network Firewall with Credentials Brokering and Requests Proxying
Control egress traffic with fine-grained network policies that can be updated at runtime. Credentials brokering injects secrets into outbound requests without exposing them inside the sandbox. Requests Proxying routes selected traffic to your own proxy server for additional security and observability.
- Dynamic policies: allow-all, deny-all, or user-defined rules
- Credentials injected on egress: never enter the sandbox
- Route any request to your own proxy server
- Live policy updates without restarting processes
Vercel Sandbox
const sandbox = await Sandbox.create({ networkPolicy: 'allow-all',});
// Install dependencies with full network accessawait sandbox.runCommand({ cmd: 'npm', args: ['install'] });
// Lock down network before running untrusted codeawait sandbox.update({ networkPolicy: { allow: { 'api.openai.com': [{ // Credentials injected on egress, never inside the sandbox transform: [{ headers: { Authorization: 'Bearer $OPENAI_API_KEY' } }], }], 'github.com': [{ // Proxy requests to any endpoint forwardURL: 'https://my-proxy-server.company.com', }], // Allow wildcard domains for egress traffic '*.vercel.app': [], // Deny all other network traffic }, },});Run each sandbox near your users, your data, or the rest of your stack
Pick a region per sandbox or set a project default for maximum performance and compliance. Vercel Sandbox runs your workload there: near your users, your data, or the rest of your stack. Pro and Enterprise teams can add failover regions, so sandbox creation keeps working even when a region is unavailable.
- Choose a region per sandbox or set a project default, on any plan
- Failover regions creation continues when a region is unavailable, on Pro and Enterprise
- Place workloads deliberately meet data-location requirements and cut latency
- Same workflow everywhere SDK, CLI, and dashboard
import { Sandbox } from "@vercel/sandbox";
const sandbox = await Sandbox.create({ region: "cdg1", failoverRegions: ["iad1", "cle1"],});Snapshots with Instant Environment Restore
Capture the complete state of a running sandbox (filesystem and installed packages), then restore it instantly. Share environments with teammates, checkpoint long-running tasks, or skip dependency installation entirely by snapshotting after setup.
- Skip dependency installation on every run
- Share identical environments with your team
- Checkpoint progress on long-running tasks
- Spin up multiple parallel instances from one snapshot
Vercel Sandbox
// Create a sandbox and set up your environmentconst sandbox = await Sandbox.create();await sandbox.runCommand('npm', ['install']);await sandbox.runCommand('npm', ['run', 'build']);
// Capture the state as a snapshotconst snapshot = await sandbox.snapshot();console.log('Snapshot created:', snapshot.snapshotId);
// Create new sandboxes instantly from the snapshotconst fast = await Sandbox.create({ source: { type: 'snapshot', snapshotId: snapshot.snapshotId },});
// Spin up multiple parallel instances from the same snapshotconst runners = await Promise.all([ Sandbox.create({ source: { type: 'snapshot', snapshotId: snapshot.snapshotId } }), Sandbox.create({ source: { type: 'snapshot', snapshotId: snapshot.snapshotId } }), Sandbox.create({ source: { type: 'snapshot', snapshotId: snapshot.snapshotId } }),]);Cost-efficient, scalable execution with Fluid compute
Vercel Sandbox runs on Fluid compute, Vercel’s optimized execution model that scales CPU and memory dynamically across millions of executions.
With Active CPU pricing, you’re billed for CPU only when code is actively running, not during idle or wait time, resulting in up to 95% lower cost for workloads with bursty or I/O-bound patterns.
Vercel Sandbox expands what our frontend infrastructure can handle. We plan to rely on it more for running untrusted code in AI workflows and for integrating tools that cannot run in a Node.js serverless function.”
Cua lets teams run computer-use agents from their apps with 100+ compatible VLMs — agents operate real desktops backed by Vercel Sandbox. Next.js playground on Vercel; agents execute in Vercel Sandbox via Cua with logs, replays, and evals.”
How much will it cost?
Estimate your monthly Vercel Sandbox costs. Adjust your workload settings and compare pricing across providers.
Launch a secure, interactive sandbox environment in milliseconds.
Quickly give Vercel Sandbox a try with your AI tool of choice.
Bootstrap a simple Node.js CLI that creates a Vercel sandbox. Use this code:
Include auth setup (vercel login && vercel link) with error handling.
Frequently asked questions
What is Vercel Sandbox?
Why use Sandbox instead of managing containers or VMs myself?
Can it run untrusted or AI-generated code safely?
How is isolation implemented?
What runtimes are supported?
Can I install system packages and use sudo?
Can I run Docker containers or use FUSE?
How long can a sandbox run?
What resources can I allocate?
Can I expose a dev server or app on a public URL?
How is network data transfer billed?
How do I monitor what’s running?
Which regions can sandboxes run in?
iad1, sfo1, cle1 and cdg1 are available with support for all Vercel regions coming soon. Choose a region per sandbox or set a project default on any plan; Pro and Enterprise teams can also configure failover regions. Active CPU and Provisioned Memory rates vary by region, see regional pricing.