Learn how to configure and customize your sandbox environment
Sandboxes are configurable cloud environments. You control CPU, memory, GPU, dependencies, environment variables, and storage so each sandbox can be customized exactly to your needs.
This gives you a minimal environment that works well for simple scripts and running untrusted code. For most real work, you’ll want to customize the resources.
Mount fast storage volumes to persist files between sessions:
Copy
Ask AI
from beam import Volume# Mount a storage volume to your sandboxvolume = Volume(name="documents", mount_path="/workspace/documents")sandbox = Sandbox(volumes=[volume])
Use volumes when you:
Are working on a project that spans multiple sessions
Need to share data between different sandbox instances
For large datasets or team sharing, you can use your own buckets:
Copy
Ask AI
from beam import CloudBucket# Connect to your S3 bucketbucket = CloudBucket( bucket_name="my-data-bucket", mount_path="/data")sandbox = Sandbox(volumes=[bucket])
# Auto-terminate after 1 hoursandbox = Sandbox(keep_warm_seconds=3600)# Manual termination only (you control when it stops)sandbox = Sandbox(keep_warm_seconds=-1)
# Start with minimal resourcessandbox = Sandbox(cpu=1.0, memory="1Gi")# If you need more power, create a new sandboxpowerful_sandbox = Sandbox(cpu=4.0, memory="8Gi")
You only pay for what you use. Start small and scale up as needed.