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.
Compute primitives built for agents
Sandboxes include 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.
Explore docsIsolated by default
Untrusted, generated code runs in isolated, non-root containers, away from your app and other workloads.
Explore docsRun anything
Execute Python with run_code, shell out to any binary with exec, and stream logs back as processes run.
Explore docsFiles in, files out
Upload inputs, let the agent work, and download artifacts through a simple filesystem API.
Explore docsSnapshots you can fork
Capture a sandbox's filesystem as an image and boot new sandboxes from that exact state to branch agent runs.
Explore docsPreview URLs
Expose any port behind an SSL-terminated, authenticated URL so you (or the agent) can see what it built.
Explore docsHow to run agent-generated code in a sandbox
Create a sandbox
Define the image (Python version, packages, even non-Python runtimes) and call create(). It's up in seconds.
Let the agent work
Run generated code, execute processes, read logs, and move files through the SDK from your agent loop.
Snapshot, expose, or terminate
Fork state with filesystem snapshots, expose ports for previews, set a TTL for long sessions, or tear it down.
# 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 to retry runs or explore 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.
Related use cases
Sandboxes for parallel RL rollouts
Forkable, restorable sandboxes for reinforcement learning rollouts.
AgentsRun computer use agents on persistent Linux desktops
Linux desktops your agents can screenshot, click, and type in.
InferenceDeploy open-source LLMs
Serve open-source LLMs behind an autoscaling, OpenAI-compatible API.
Give your agents their own machines
Sign up, install the CLI, and launch a sandbox, VM, or GPU from your terminal or your coding agent.