Skip to main content
Placement determines which compute runs your sandbox. Serverless uses CoreWeave-managed compute. CoreWeave Kubernetes Service (CKS) placement uses compute in a 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. Forge API keys support serverless sandboxes. CoreWeave API access tokens support both serverless and cluster sandboxes. The environment variable and authentication strategy identify the credential, independently of the placement mode: Choose one credential explicitly, even if both variables are set. Use the same account to create, reconnect to, list, and stop a sandbox.
Choose a Forge API key if you don’t have a CoreWeave console account or prefer Forge billing:
  1. Open Forge API key settings. 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:
In Python, install cwsandbox[wandb] and select auth=AuthStrategy.WANDB. In TypeScript, use the @coreweave/cwsandbox/wandb entry point. Setting WANDB_API_KEY alone does not switch the Python client from its CoreWeave default. The serverless quickstart includes complete examples.

Select a placement mode

Both Python and TypeScript support serverless and CKS placement. Serverless is the default. The PlacementMode reference lists the supported mode values. Both CKS 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. Select CKS 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.

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 Forge API 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 November 4, 2026