# Best sandbox for the Vercel AI SDK in 2026 The best sandbox for the AI SDK plugs in as ordinary tools, works with any model and bills CPU only while code runs. **With Runtime an AI SDK agent gets a full Linux microVM from one line, `tools: runtimeTools(sbx)`, with any model the SDK can call.** The four tools run commands and read, write and list files in a Firecracker microVM with its own kernel. The same machine is also a sandbox for the SDK's `HarnessAgent`, so Claude Code, Codex or Pi can run in it. Fifty thousand two-minute chat turns a month, each busy for 10 CPU-seconds, cost $53.47 on Runtime, $159.11 on Vercel Sandbox and $276.00 on E2B at their published rates, checked 23 September to 2 October 2026. ## How does the AI SDK connect an agent to a sandbox? The SDK runs tools in your own process unless a tool sends the work elsewhere. Its [tools registry](https://ai-sdk.dev/tools-registry) and [harness docs](https://ai-sdk.dev/docs/ai-sdk-harnesses/harness-agent) list these ways to run code: | Route | Where code runs | Models | | ------------------------------------------- | ----------------------------------- | ------ | | `@ai-sdk/sandbox-just-bash` | A simulated bash in your process | Any | | `openai.tools.codeInterpreter()` | OpenAI's hosted container | OpenAI | | `anthropic.tools.codeExecution_20260120` | Anthropic's hosted container | Claude | | `code-execution`, `bash-tool`, Vercel's own | Vercel Sandbox | Any | | `bedrock-agentcore` | AWS Bedrock's code interpreter | Any | | `runtimeTools(sbx)`, `createRuntimeSandbox` | A Runtime microVM your code created | Any | just-bash describes itself as "a simulated bash environment with virtual filesystem", so it cannot install a package or run a real binary. A provider's own code tool ties the agent to that provider's models. Runtime's tools are plain AI SDK tools, so changing models is a one-word change. ## What matters in a sandbox for the AI SDK? - **Any model.** The tools are ordinary AI SDK tools, so Claude, GPT, Gemini and open models through the AI Gateway all use the same sandbox. - **A real machine.** Ubuntu 24.04 with `sudo`, Python, Node.js, Bun and gcc, where pandas, NumPy and matplotlib are already installed, and `pip install` and `npm install` work when the model needs more. - **Chat sessions that cost nothing idle.** `Sandbox.getOrCreate("chat-42")` gives each conversation one named sandbox that pauses itself after 60 seconds with nothing happening and wakes with its files, memory and processes on the next turn. - **Streaming routes.** `streamText` keeps the same tools; stop the sandbox in `onFinish`, and a lease stops it if the client disconnects. - **Harness agents too.** `createRuntimeSandbox()` from `withruntime/ai-harness` is a sandbox for `HarnessAgent`, with ports for bridge harnesses such as Claude Code and Codex ([guide](/docs/vercel-ai-sdk)). ## What does an AI SDK chat app cost per month? Fifty thousand chat turns, each two minutes on a 2 vCPU, 4 GiB sandbox and busy for 10 CPU-seconds, at each provider's published rates: | Provider | Isolation | CPU billed on | A month of turns | | -------------- | ----------------------- | ----------------- | --------------------------------- | | Runtime | Firecracker microVM | Measured use | $53.47 | | Vercel Sandbox | Firecracker microVM | Measured use | $159.11 | | E2B | Firecracker microVM | Every vCPU held | $276.00 | | Daytona | Containers by default | Every vCPU held | $276.00 | | Modal | gVisor, a shared kernel | The CPU requested | $396.60 | Runtime costs 66% less than Vercel Sandbox and 81% less than E2B for the same month. ## A run on Runtime, recorded 2 October 2026 ```ts check import { generateText, stepCountIs } from "ai"; import { Sandbox } from "withruntime"; import { runtimeTools } from "withruntime/ai"; await using sbx = await Sandbox.create(); const { text } = await generateText({ model: "anthropic/claude-sonnet-4.6", tools: runtimeTools(sbx), stopWhen: stepCountIs(10), prompt: "Print the first 15 Fibonacci numbers with Node.", }); console.log(text); ``` We ran this `generateText` loop with `ai` 7.0.87 and the SDK's mock model in place of Claude, so the model's two tool calls were scripted and the AI SDK ran them against a live sandbox: ```text runtime_write_file fib.mjs Wrote 132 bytes to /workspace/fib.mjs runtime_exec node fib.mjs && node --version exitCode 0 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 v24.21.0 ``` Node.js 24 was there with nothing installed first. Streaming routes, chat sessions and spending limits are in [code execution for the AI SDK](/integrations/vercel-ai-sdk). ## When might another sandbox fit better? - **No sandbox at all.** If the model only needs shell-like text tools over files your app already holds, just-bash runs in your process with nothing to create. ## Sources Checked 2 October 2026. - [AI SDK tools registry](https://ai-sdk.dev/tools-registry): the code execution and sandbox tools and where each runs - [AI SDK HarnessAgent](https://ai-sdk.dev/docs/ai-sdk-harnesses/harness-agent): the sandbox adapters and what bridge harnesses need - [just-bash](https://github.com/vercel-labs/just-bash): its own description - Each provider's published rates, checked 23 September to 2 October 2026, as the [pricing guide](/docs/pricing) lists them - The recorded run: Runtime's TypeScript SDK with `ai` 7.0.87's `MockLanguageModelV4`, against production on 2 October 2026