Sandboxes

Secure code execution for AI agents and developer tools

Run untrusted code in isolated environments. Give your AI agents, code interpreters, and developer tools a secure place to execute code, install packages, and interact with the filesystem.

Fully isolated

Each sandbox runs in its own secure container. Execute AI-generated or user-submitted code with zero risk to your infrastructure.

Fast spin-up

Sandboxes start in milliseconds, not minutes. Execute code immediately without waiting for cold starts.

Bring your own images

Use standard container images with your own dependencies, tools, and runtimes. Full flexibility without lock-in.

How Sandboxes work

Background Pattern

SDK-driven control

Import @cloudflare/sandbox and manage the entire sandbox lifecycle from your Worker. Clone repos, execute commands, read/write files — all via simple async methods.

Background Pattern

Built on Containers

Sandboxes run on Cloudflare Containers, so you get the same global placement, automatic scaling, and pay-per-use pricing.

Background Pattern

Real-time streaming

Stream stdout and stderr live from long-running commands. Get immediate feedback without polling.

Background Pattern

Code interpreter built-in

Run Python or JavaScript code directly with runCode(). Rich outputs like charts, tables, and images are parsed automatically.

Background Pattern