# Run untrusted code with Vercel Sandbox

**Published:** June 25, 2025 | **Authors:** Guðmundur Bjarni Ólafsson, Laurens Duijvesteijn, Javi Velasco, Mariano Cocirio, Ali Smesseim, Fabio Benedetti, Andy Waller

---

Vercel Sandbox is a secure cloud resource powered by [Fluid compute](https://vercel.com/fluid). 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](https://vercel.com/docs/vercel-sandbox/sdk-reference), supporting execution times up to 45 minutes.

```javascript
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.from(result.text) },
  ]);

  await sandbox.runCommand({
    cmd: "node",
    args: ["script.js"],
    stdout: process.stdout,
    stderr: process.stderr,
  });
```

Sandbox uses the Fluid compute model and charges based on [Fluid’s new Active CPU time](https://vercel.com/changelog/lower-pricing-with-active-cpu-pricing-for-fluid-compute), meaning you only pay for compute when actively using CPU. See [Sandbox pricing](https://vercel.com/docs/vercel-sandbox#pricing) for included allotments and pricing for Hobby and Pro teams.

Now in [Beta](https://vercel.com/docs/release-phases#beta) and available to customers on all plans. Learn more about [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox).

---

📚 **More updates:** [View all changelog entries](/changelog/sitemap.md) | [Blog](/blog/sitemap.md)