Skip to main content
Placement determines which compute runs your sandbox. Serverless uses CoreWeave-managed compute. Cluster placement uses compute in a CoreWeave Kubernetes Service (CKS) cluster in your organization. Spillover retries sandbox creation in the other mode when the initial placement fails.

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:
  1. Open wandb.ai/authorize. Sign in, or create an account through the same link.
  2. Copy your API key and set it in the terminal where you run the client:
The examples use a key from wandb.ai. In Python, install 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:
  1. 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.
  2. On the Tokens page, click Create Token, complete the token details, and click Create.
  3. Copy the Token Secret and set it in the terminal where you run the client:
If you can’t create a token, ask your administrator for the Access Token Admin role. The token secret is shown only once. For more information, see Manage API access tokens. In Python, select 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. The PlacementMode reference lists the supported mode values. Select cluster placement explicitly:
Use placement_mode="cks". Add runner_ids to restrict placement to particular runners:
Without 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.
Both cluster examples read 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, set placement_spillover="cks_then_serverless":
The example specifies CPU and memory for both attempts. Each mode applies its own policy, so a request must satisfy the policy of the mode where it runs. Set 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.
Last modified on September 25, 2026