
bespokelabs-sandbox, is one Python API to create a sandbox, run code and commands, move files, and run CLI agents like Claude Code and Codex, on Docker, Daytona, E2B, Modal, and other providers.
boxd is one of those providers since version 0.4.0. Each sandbox is an isolated boxd machine, a full Ubuntu 24.04 VM with Docker, Python, Node and git, and switching to it from another provider is a change of the backend name.
Set up
1
Install the library with the boxd extra
2
Create an API key
BOXD_ORG picks one.3
Run code in a machine
with block deletes the machine.Limit the network
network= sets an egress allowlist on the machine before your code runs:
mode="none" blocks everything, and sb.set_network() changes the policy of a running sandbox.
Serve a port
expose_port() gives a port in the machine a public HTTPS URL:
Options
image=, dockerfile= and gpu= are refused: a machine boots boxd’s Ubuntu image and has no GPU. Run your image with Docker inside the machine, or start from a snapshot.
What each machine gets
- Isolation, always: every machine is isolated, with no boxd credentials inside and no route to your other machines.
- No standby mid-job: auto-suspend is off, so a long job between commands is not paused.
- Cleanup on failure: if creating a sandbox fails after boxd made the machine, the library deletes it, and finds it by a label it set when it has no id yet.
- A clean end: leaving the
withblock, orsb.destroy(), deletes the machine. Snapshots outlive it, so delete them when you no longer need them.
Read more
bespokelabs-sandboxon GitHub: the SDK reference, the agent guide, and the control plane- Provider feature matrix
bespokelabs-sandboxon PyPI- Sandboxes on boxd