Create and run code
run_code() waits by default and returns captured stdout, stderr, and the exit code. process.exec() returns a process handle immediately; call wait() when you need its exit code.
Start a web server
Lifecycle and reconnecting
The Python sandbox defaults to 1 CPU, 128 MiB of memory, Python 3.11, and a 600-second lifetime. Setkeep_warm_seconds=-1 for manual termination, or reset the remaining lifetime with sb.update_ttl(300).
Save sb.container_id to reconnect while the sandbox is still alive:
Capabilities
- Processes: commands, Python execution, stdin, streaming, cancellation, and async calls.
- Filesystem: read/write bytes and text, transfer files, search, and replace.
- Networking: preview ports and runtime egress policies.
- Docker: build images and run nested containers or Compose services.
- TypeScript SDK: create and operate sandboxes from Node.js.