# Cloudflare Sandbox SDK [[Cloudflare]] Sandbox SDK is a managed-container runtime for executing untrusted code from AI agents and applications. Each sandbox is an isolated [[Cloudflare Containers]] instance with a filesystem, command execution, a code interpreter, and preview URLs — addressable from a [[Cloudflare Workers]] via a Durable-Object-backed handle. It's the Cloudflare answer to E2B, Modal sandboxes, and Daytona: a way for LLM-driven agents to run arbitrary Python, Node, shell commands, install packages, and serve HTTP previews — without the host having to trust the code. ## Why It Matters AI agents that write and execute code need a place to run that code that won't compromise the host. Doing this safely yourself (containers, network isolation, filesystem limits, lifecycle management) is operationally heavy. Sandbox SDK handles it: spin up a sandbox in milliseconds, run code, capture output, kill it. Pairs naturally with [[Cloudflare Agents SDK]] — the agent owns the sandbox lifecycle, the sandbox isolates the side effects. ## Core Primitives - **Sandbox lifecycle**: create, attach, destroy - **Commands**: shell command execution with captured stdout/stderr - **Files**: read, write, list across the sandbox filesystem - **Code interpreter**: Python/Node REPL-style execution - **Preview URLs**: expose any port from the sandbox via a public HTTPS URL ## Common Use Cases - **AI code execution** — agent writes Python, runs it, reads the output - **Code interpreters** for chat apps (think ChatGPT's "advanced data analysis") - **CI/CD-like systems** running untrusted user-submitted code - **Interactive dev environments** spawned on demand for users - **Reproducible script runs** with isolated filesystems ## References - Sandbox SDK home: https://developers.cloudflare.com/containers/ - GitHub: https://github.com/cloudflare/sandbox-sdk ## Related - [[Cloudflare]] - [[Cloudflare Workers]] - [[Cloudflare Durable Objects]] - [[Cloudflare Containers]] - [[Cloudflare Agents SDK]] - [[Wrangler]] - [[AI Agents]] - [[microVM]] - [[Docker Sandboxes]] - [[OpenSandbox]] - [[Vercel Sandboxes]] - [[Sandcastle (AI)]]