Learn how to configure and customize your sandbox environment
You can specify exactly what resources and environment you need, similar to any other Beam container. You control CPU, memory, GPU, Python packages, and more. Here’s how to configure it for a few different use cases.
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.