Key features
Secure isolation
Each sandbox runs in its own container with complete isolation from other workloads
Edge-native
Runs on Cloudflare’s global network for low-latency code execution worldwide
Code interpreter
Execute Python and JavaScript with rich outputs including matplotlib charts
File system access
Read, write, and manage files with full POSIX filesystem support
Command execution
Run any command with streaming support for real-time output
Preview URLs
Expose services running in your sandbox with public URLs
Git integration
Clone repositories directly into your sandbox environment
Background processes
Run long-running processes and manage their lifecycle
Use cases
AI code execution
Give AI models the ability to write and execute code safely. Perfect for:- AI agents that need to run Python for data analysis
- Code generation tools that validate outputs
- Interactive coding assistants
Development environments
Build cloud-based IDEs and development tools:- Browser-based code editors
- Interactive tutorials and learning platforms
- Code playgrounds and REPLs
Data analysis platforms
Run user-submitted data processing code:- Jupyter-style notebook environments
- Custom data transformation pipelines
- Statistical analysis tools
CI/CD systems
Execute build and test workflows:- Automated testing environments
- Build systems for user projects
- Deployment automation
How it works
The Sandbox SDK is built on Cloudflare’s container platform and uses Durable Objects to manage sandbox lifecycle:Create a sandbox
Your Worker gets a reference to a sandbox using
getSandbox(). Each sandbox is backed by a Durable Object that manages the container lifecycle.Execute code
Call methods like
exec(), writeFile(), or runCode() to interact with the sandbox. The SDK communicates with the container runtime over HTTP.Architecture
- Worker: Your application code that calls the SDK
- Sandbox Durable Object: Manages container lifecycle and routes requests
- Container Runtime: Bun-based HTTP server running inside Docker containers
- Shell/Filesystem: Ubuntu 22.04 with Python 3.11, Node.js 20, Git, and common utilities
What’s included
Each sandbox container comes pre-installed with:- Python 3.11 with matplotlib, numpy, pandas, and ipython
- Node.js 20 LTS with npm
- Bun 1.x runtime
- Git for repository operations
- Common utilities: curl, wget, jq, and more
Quick example
Next steps
Installation
Install the SDK and set up your first project
Quickstart
Build your first sandbox application in 5 minutes
API reference
Explore the complete SDK API
Examples
See real-world applications and use cases
Status
The Sandbox SDK is in open beta. The API is stable and safe for production use, but may evolve based on feedback before v1.0.