Vercel Sandbox is a secure cloud resource powered by Fluid compute . It is designed to run untrusted code, such as code generated by AI agents, in isolated and ephemeral environments.
Sandbox is a standalone SDK that can be executed from any environment, including non-Vercel platforms. Sandbox workloads run in ephemeral, isolated microVMs via the new Sandbox SDK , supporting execution times up to 45 minutes.
import { Sandbox } from "@vercel/sandbox" ;
import { generateText } from 'ai' ;
const result = await generateText ( {
model : "anthropic/claude-4-sonnet-20250514" ,
prompt : ` Write a Node.js script that prints a Haiku poem to stdout. ` ,
system : `
You are a developer that responds with the content of a single Node.js script.
You must include only the code without any markdown, nothing else.
Just include Javascript code and no characters before or after the code.
` ,
} ) ;
const sandbox = await Sandbox . create ( ) ;
await sandbox . writeFiles ( [
{ path : "script.js" , stream : Buffer .…