Skip to main content
A sandbox is a disposable environment your code creates, uses, and throws away. In about five minutes you’ll create one, run code in it, serve a URL, fork it from a memory snapshot, and attach a GPU. For a persistent machine that keeps its disk between sessions, start with the VM quickstart.
Using Cursor, Claude Code, or Codex? Run beam setup agent to connect your coding agent to your workspace. See agent setup.

Install and Sign In

Finish signing in through your browser, then run beam whoami to check your workspace.

Run Code, Serve a URL, and Fork

Save this as sandbox.py and run python sandbox.py:
sandbox.py
Preview URLs are public. Add authentication in your app before serving anything sensitive.

Add a GPU

Attach a GPU with one argument:
Requesting a GPU doesn’t install CUDA libraries. Add packages such as torch to the sandbox image.

Control Outbound Traffic

Each sandbox is isolated from your app and other workloads. Block outbound traffic or allow only specific hostnames, wildcard domains, IPs or CIDRs:
To give the agent credentials, use brokered secrets. The guest receives placeholders; the worker supplies the real values only in HTTPS headers to approved hosts. With block_network=True and secrets, only their approved hosts are reachable. The guest has no automatic Beam workspace token.

Next Steps

Give an Agent a Dev Box

Create a persistent VM that pauses when idle.

Snapshots

Save filesystem or memory state and fork it.

Networking

Preview URLs and outbound rules.

TypeScript SDK

Create and operate sandboxes from Node.js.