What problem does it solve?
Sandbox SDK enables secure, isolated execution of commands and AI-generated code so you can run untrusted workloads without exposing your main environment.
Core Features & Use Cases
- Secure isolated execution on Cloudflare Workers: Runs shell-style commands and code interpreter-style execution inside Sandbox containers for safer evaluation.
- LLM-friendly code execution with persisted context: Uses
createCodeContext and runCode to support multi-step code workflows where state matters.
- Workspace file and port operations: Creates directories, reads/writes files, lists artifacts, and exposes ports for preview URLs.
Example use case: you want to execute AI-generated Python to transform uploaded data, write results into /workspace, and expose a temporary HTTP preview endpoint—without risking your host system.
Quick Start
Configure wrangler.jsonc and re-export Sandbox from your Worker entry, then ask the AI to help you implement a Worker route that calls getSandbox(env.Sandbox, sessionId) and runs runCode() for the requested language and code.