AI EngineerGuide

Upstash Box - Serverless Sandbox for AI Agents

by Ashik Nesin Ashik Nesin

If you need to run AI generated code, it is not a good idea to run in your machine as it might cause BIG security concerns (imagine it wiping out other data or something like that)

So it is better to use sandbox to run those AI generated code.

There are things like Modal or e2b.dev which does a great job but it is intented for a heavy usage and might require you to pay a lot (fixed commitment)

That’s where Upstash Box comes in.

You get:

2026-03-18-at-23.11.492x.png

2026-03-18-at-23.21.522x.png

How it works?

Simple Code Execution

import { Box } from "@upstash/box";

const box = await Box.get("example-slug-48753", {
  apiKey: process.env.UPSTASH_BOX_API_KEY,
});

const run = await box.exec.code({
  lang: "js",
  code: "const x = Math.floor(Math.random() * 100); console.log('Random number:', x);",
});

console.log(run.result); // Random number: 42

Building website using AI Agents

import { Box, Runtime, ClaudeCode } from "@upstash/box";
 
const box = await Box.create({
  runtime: Runtime.Node,
  agent: { model: ClaudeCode.Opus_4_6 },
});
 
// Run an agent inside your box
const run = await box.agent.run({
  prompt: "Build a minimal portfolio website with Tailwind",
});
console.log(run.result);
 
// Or run any command directly
await box.exec.command("npm run build");

Reference

#Upstash-Box #Sandbox

Stay Updated

Get the latest AI engineering insights delivered to your inbox.

No spam. Unsubscribe at any time.