Compare placement modes
Choose a mode based on who manages the capacity and policy:
Follow the serverless quickstart or Use your own compute to create your first sandbox.
Choose and get credentials
Your credential determines which account owns the sandbox and is billed for its usage. W&B API keys support serverless sandboxes. CoreWeave API access tokens support both serverless and cluster sandboxes.W&B API key
Choose W&B if you don’t have a CoreWeave console account or prefer W&B billing:- Open wandb.ai/authorize. Sign in, or create an account through the same link.
-
Copy your API key and set it in the terminal where you run the client:
cwsandbox[wandb] and select AuthStrategy.WANDB. In TypeScript, import the client from @coreweave/cwsandbox/wandb. The serverless quickstart includes complete examples for both languages.
CoreWeave API access token
Choose CoreWeave to use your CoreWeave organization’s billing or run sandboxes on its cluster:- Ask your administrator to create or update an Access Policy granting you the Sandbox User role to run sandboxes. Administrators who enable runners and configure their policies need Sandbox Admin, which includes sandbox execution permissions. See Create an access policy and Sandbox roles.
- On the Tokens page, click Create Token, complete the token details, and click Create.
-
Copy the Token Secret and set it in the terminal where you run the client:
AuthStrategy.COREWEAVE_API_KEY. In TypeScript, import the client from @coreweave/cwsandbox/node.
Select a placement mode
Both Python and TypeScript support serverless and cluster placement. Serverless is the default. ThePlacementMode reference lists the supported mode values. Select cluster placement explicitly:
- Python
- TypeScript
Use Without
placement_mode="cks". Add runner_ids to restrict placement to particular runners:runner_ids, CKS placement can use any eligible runner in your organization. For serverless, omit both fields or set placement_mode="serverless" without runner_ids.CWSANDBOX_API_KEY. Complete credential setup, then follow Use your own compute to enable a runner or the serverless quickstart to install the TypeScript client.
Spill over between modes
Automatic spillover is available in the Python client. The TypeScript client supports selecting either placement mode, but doesn’t provide automatic spillover. Spillover retries sandbox creation once in the alternate mode for eligible placement failures, such as unavailable capacity or no suitable runner. It doesn’t move a running sandbox between modes. Use a CoreWeave API access token for an organization with both serverless access and a configured CKS runner. A W&B key alone doesn’t provide CKS access. To prefer CKS and fall back to serverless, setplacement_spillover="cks_then_serverless":
placement_spillover to one of the following options to control fallback:
For the supported fallback values, see the
PlacementSpillover reference. For resource and timeout settings, see Sandbox configuration.