Skip to main content
The Bespoke Labs logo mark and wordmark inside the boxd card. Bespoke Labs builds RL environments and infrastructure for training agents. Its open-source sandbox library, 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

Machines are created and billed in the key’s organization. When the key can reach more than one organization, BOXD_ORG picks one.
3

Run code in a machine

The run took 8 seconds, machine included. Leaving the 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:
The URL is public, with no login in front of it. The first one on a machine waits for its TLS certificate, which takes about 20 seconds.

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 with block, or sb.destroy(), deletes the machine. Snapshots outlive it, so delete them when you no longer need them.

Read more