vercel-sandbox

Run untrusted or AI-generated code in ephemeral Firecracker microVMs via the @vercel/sandbox SDK.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/ridhijain709/AIPORSCHE --skill vercel-sandbox-ridhijain709
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vercel-sandbox
Source: https://github.com/ridhijain709/AIPORSCHE/tree/main/.agents/skills/vercel-sandbox/upstream
Command: npx skills add https://github.com/ridhijain709/AIPORSCHE --skill vercel-sandbox-ridhijain709

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @vercel/sandbox.

What problem does it solve? Running untrusted or AI-generated code safely is hard: in-process sandboxes like vm2 have known escapes, and child_process or eval share your process and credentials. This Skill provides instructions for executing code inside isolated Firecracker microVMs with controlled networking, filesystem access, and lifecycle management. ## Core Features & Use Cases - Isolated Code Execution: Create on-demand Linux VMs, run commands, read and write files, and stop or snapshot sessions using the @vercel/sandbox JavaScript SDK, Python SDK, or CLI. - Egress Firewall & Credential Brokering: Apply networkPolicy rules (deny-all or domain allow-lists) and inject auth headers at the firewall so secrets never enter the VM. - Persistence, Snapshots & Drives: Resume persistent sandboxes by name, boot from filesystem snapshots to skip reinstalls, and mount shared drives across sandboxes. - Use Case: An AI coding agent needs to execute generated code and call an LLM API. Create a sandbox with an allow-list permitting only ai-gateway.vercel.sh, broker the OIDC token at the firewall, and run the agent without exposing any credential inside the VM. ## Quick Start Ask the assistant to create a Vercel Sandbox, run a Python command inside it, print the output, and stop the sandbox in a finally block.

Frequently Asked Questions about vercel-sandbox

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run untrusted code safely in Node.js?

Use @vercel/sandbox to run untrusted code in a separate Firecracker microVM instead of in-process options like vm2, which have known escapes. Create a sandbox with Sandbox.create(), run commands with runCommand, and call stop() in a finally block.

How do I expose a port from a Vercel Sandbox?

Pass the port in the ports array at create time, start your server bound to 0.0.0.0 rather than 127.0.0.1, then read the public URL with sandbox.domain(port). Poll until the port answers inside the VM before using the URL.

Does Vercel Sandbox work outside Vercel deployments?

Yes. On Vercel it authenticates automatically via OIDC, but locally you run vercel link and vercel env pull for a VERCEL_OIDC_TOKEN, and in CI you set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID.

Why does runCommand fail with pipes or redirects?

runCommand invokes a binary directly with no shell, so pipes, redirects, &&, and globs do not work. Wrap such commands in bash -c, and note that non-zero exit codes do not throw, so check result.exitCode.

How do I keep an AI agent's API key out of the sandbox?

Use credential brokering: set a networkPolicy allow-list for the target domain with a transform rule that injects the authorization header at the egress firewall. The VM never holds the secret and cannot reach other TLS hosts.

What are the limits of Vercel Sandbox sessions?

Sessions last up to 45 minutes on Hobby and 24 hours on Pro and Enterprise, with 1 to 32 vCPUs depending on plan, 15 ports, and 64 GB disk. Persistent sandboxes resume into new sessions, so total lifetime is effectively unbounded.