CoreWeave sandboxes are in public preview. For access, contact your CoreWeave account team, CoreWeave Support, or email support@coreweave.com.
Variables
The platform sets the following variable in every sandbox:
The platform sets these variables regardless of which SDK or API version you use.
Don’t parse the hostname to obtain the sandbox ID. A sandbox’s hostname begins with the sandbox ID, but it carries a generated suffix that changes if the underlying pod restarts. Use
CW_SANDBOX_ID instead.Read a variable
Platform variables are available to each container’s main process, to any process it starts, and to processes started withexec and streaming execution. The exception is a program that clears its environment before starting a child.
- Python
- TypeScript
- Shell
Override a variable
Platform variables are defaults, not reserved names. If you set a variable of the same name on your sandbox, the sandbox uses your value and the platform does not apply its default. Replace[YOUR-VALUE] with the value you want the sandbox to report:
- Python
- TypeScript
- Any value counts, including an empty string. Setting
CW_SANDBOX_IDto""produces a variable that is present and empty. The platform does not treat an empty value as unset and does not replace it. - Secrets count as overrides. A secret mapped to the same variable name suppresses the platform default in the same way a direct value does.
- A policy cannot override platform variables. The name is reserved against operator configuration, so a cluster’s policy cannot silently replace a value you set.
Metadata only, not identity
CW_SANDBOX_ID is advisory metadata. Because it can be overridden, code inside a sandbox can report any value.
Sandboxes with more than one container
Each container receives the value set on the sandbox’s first container, unless that container setsCW_SANDBOX_ID itself. An explicit value takes precedence for the container that sets it.
This has two consequences:
- If you override the variable on the first container, every other container that sets nothing receives your override.
- If you override it to an empty string on the first container, the other containers do not receive the variable at all.
Behavior across the sandbox lifecycle
CW_SANDBOX_ID behaves as follows across a sandbox’s lifetime:
- The value is fixed for the life of the sandbox. The platform assigns it at creation, and it does not change if the underlying pod restarts.
- A restored sandbox is a new sandbox. Restoring from a file system snapshot creates a sandbox with a new ID, and
CW_SANDBOX_IDcarries that new value. Any earlier ID your application wrote into a snapshot volume persists as your own data and is not updated.