Choose the container, network, and dependencies your agent runs in.
An Environment defines the runtime used by a Session, including its environment type, preinstalled dependencies, setup script, and metadata. You can use the default managed Environment, create an Environment with tools for a specific task, or connect a self-hosted runtime.
config.type can be "cloud" or "self_hosted".For self_hosted, the config can contain the type and an optional setup_script:
Copy
{"type": "self_hosted"}
Self-hosted Environments do not launch a managed cloud container. External workers use the Work API to poll, acknowledge, heartbeat, and stop Session work for that Environment. A self_hosted config supports only type and an optional setup_script.For cloud, the config can include packages and setup_script.
config.setup_script is a shell script executed during sandbox preparation, after packages are installed. It runs through /bin/bash -lc. Use it for initialization steps that cannot be expressed as packages - for example, cloning a repository, writing config files, or warming caches.
On success a completion marker is written inside the sandbox so the script does not run twice in the same sandbox; when the sandbox is recreated, the script runs again. A non-zero exit aborts session startup, and the error response includes the exit code and a stderr excerpt.
Q: How long do I have to wait after creating an Environment before I can use it?A: A new Environment is immediately usable. The actual container provisioning, including dependency installation, happens when a Session starts.Q: Can I pin package versions?A: pip and npm packages support pinning, such as "pandas==2.1.0" or "typescript@5.0.0". apt packages use the default version from the system repository.Q: How many Environments can I create per account?A: There is no hard limit. Create only what you need and use a naming convention to keep things organized.