# Give your AI agents a safe place to run code

Run agent-generated code in isolated sandboxes that boot in under a second, with filesystem access, exposed ports, and snapshots.

```
sb = sandbox.create()
```

Sandbox created: sb-9f2c (0.8s)

```
sb.exec("python train.py")
```

Training on B200... loss=0.42

Checkpoint saved to /outputs/step_500

```
sb.snapshot()
```

Snapshot saved: snap-b41e

https://sb-9f2c.sandbox.beam.cloud

## Compute primitives built for agents

Everything an agent needs. Process management, file system operations, and access to stdout and stderr.

### **Sub-second boots**  
Sandboxes cold boot in under a second, dependencies included, so agent loops aren't stuck waiting on infrastructure.

### **Isolated by default**  
Untrusted, generated code runs in isolated, non-root containers — away from your app and other workloads.

### **Run anything**  
Execute Python with run_code, shell out to any binary with exec, and stream logs back as processes run.

### **Files in, files out**  
Upload inputs, let the agent work, and download artifacts through a simple filesystem API.

### **Snapshots you can fork**  
Capture a sandbox's filesystem as an image and boot new sandboxes from that exact state — perfect for branching agent runs.

### **Preview URLs**  
Expose any port behind an SSL-terminated, authenticated URL so you (or the agent) can see what it built.

## Give your agents a computer

01

### Create a sandbox

Define the image — Python version, packages, even non-Python runtimes — and call create(). It's up in seconds.

02

### Let the agent work

Run generated code, execute processes, read logs, and move files through the SDK from your agent loop.

03

### Snapshot, expose, or terminate

Fork state with filesystem snapshots, expose ports for previews, set a TTL for long sessions, or tear it down.

### Example Code

```python
# Process management
process = sandbox.process.exec("python3", "train.py")
for line in process.logs:
    print(line, end="")

# Filesystem in and out
sandbox.fs.upload_file("data.csv", "/workspace/data.csv")
sandbox.fs.download_file("/workspace/output.csv", "results.csv")

# Keep the session alive for an hour
sandbox.update_ttl(3600)

# Snapshot the filesystem to fork or resume later
image_id = sandbox.create_image_from_filesystem()
```

## Frequently asked questions

### How isolated are sandboxes?+
Each sandbox runs in its own isolated, non-root container, separated from your other workloads. For stricter requirements, Beam also offers a self-hosted deployment that keeps everything inside your own VPC.

### Can agents run things other than Python?+
Yes. Sandboxes run arbitrary processes — start from any base image (Node, for example) and exec whatever the agent needs.

### How long can a sandbox stay alive?+
As long as you want. Sandboxes shut down automatically by default, but update_ttl lets you extend sessions or keep them running indefinitely.

### Can I resume or branch an agent's environment?+
Yes. Snapshot the filesystem to an image, then boot any number of new sandboxes from that state — ideal for retries and exploring branches.

### Which agent frameworks does this work with?+
Any of them. The Sandbox SDK is plain Python, so LangChain tools, custom loops, or anything that can call a function can drive it.
