Skip to main content
This guide covers both ways to run a sandbox: on serverless capacity CoreWeave operates, or on a CoreWeave Kubernetes Service (CKS) cluster you own. Start with Choose a placement mode, then follow the section for the mode you picked. For background on the components and how they fit together, see About CoreWeave sandboxes.
CoreWeave sandboxes are in public preview. For access, contact your CoreWeave account team, CoreWeave Support, or email support@coreweave.com.

Choose a placement mode

Placement mode decides which runners a sandbox can land on. Serverless is the default: omit the mode and the platform places the sandbox on a CoreWeave-operated pool. You don’t have to pick one permanently. Once you’ve set up both, Spill over between modes covers falling back from one to the other when the first can’t place a sandbox.

Run a sandbox on serverless capacity

Serverless placement needs no runner and no policy of your own. You need the following:
  • Serverless enabled for your organization. If it isn’t, sandbox creation fails with CWSANDBOX_SERVERLESS_NOT_ALLOWED. Contact support to request access.
  • A credential, either a CoreWeave API access token or a Weights & Biases API key. See Choose a credential.

Choose a credential

Serverless accepts two credentials, and which one you present decides which account the sandbox belongs to and bills to. The credential identifies your organization on its own. No organization or cluster field appears in the request. Two limits apply to the W&B path today:
  • The Python client has no built-in W&B credential path. Its built-in auth mode reads CWSANDBOX_API_KEY and sends it as a bearer token. To present a W&B key from Python, register your own auth mode with set_auth_mode.
  • W&B Dedicated customers can’t reach serverless sandboxes with the API key from their dedicated instance. Supporting it is new authorization and billing work. Until then, use a CoreWeave access token if your organization is also a CoreWeave customer, or a W&B trial account.
Serverless sandbox usage is metered while the product is in public preview, but charges aren’t posted until the product reaches general availability.
Set your credential. For a CoreWeave access token, replace [API-ACCESS-TOKEN] with the Token Secret value:
For a W&B API key, replace [WANDB-API-KEY] with the key from wandb.ai/authorize:
Then run a sandbox that prints “Hello!”:
Sandbox.run() defaults to serverless placement. Pass placement_mode="serverless" to state it explicitly.
Serverless pins each container’s limits equal to its requests, so the sandbox gets exactly the CPU and memory it asks for.

Deploy sandboxes on your own CKS cluster

The rest of this page walks through the CKS path end to end. You’ll do the following:
  • Deploy a runner and set the policy it carries.
  • Run your first sandbox from the Python client.
  • Delete the runner when you’re done.
The administrator step deploys the runner and sets its policy. The researcher step runs sandboxes against it. Each admin step in the following sections shows the same operation through the CoreWeave Intelligent CLI (cwic) and through direct curl calls against the control plane REST API. Pick whichever fits your workflow. The wizard and from-file cwic tabs are equivalent. The from-file and curl tabs accept YAML or JSON bodies, which makes them a natural interface for CI scripts and for agents (such as Claude Code or Codex) that author runner and policy documents on your behalf.

Prerequisites

For the administrator steps, complete the following:
  • A CKS cluster in your CoreWeave organization, in the STATUS_RUNNING state. View your clusters and their status on the Clusters page in the cloud console. Note the cluster’s zone and name. Both are reused in later steps.
  • The SANDBOX_ADMIN action in Identity and Access Management (IAM), which lets you create runners and set their policy. Create or update an access policy that grants this action on the Access Policies page in the cloud console.
  • A CoreWeave API access token. Generate one from the Tokens page in the cloud console and copy the Token Secret value. For more information about tokens, see Manage API Access Tokens.
Then set up your preferred interface:
Install the CoreWeave Intelligent CLI (cwic), then sign in with the token:
The token is stored in your local cwic config. Subsequent cwic commands read it automatically. No environment variable is required.
For the researcher step, complete the following:
  • The SANDBOX_USER IAM action, which lets you create sandboxes against the data plane. Granting SANDBOX_ADMIN also grants SANDBOX_USER.
  • A CoreWeave API access token. For more information, see Manage API Access Tokens.
  • Python 3.11 or newer in the environment that runs the SDK. The Python version inside the sandbox is independent and is set by the container_image you pass to Sandbox.run().
When you meet these requirements, work through the following sections in order.

Deploy a runner and set its policy

A runner is the Kubernetes workload that schedules sandbox pods on your cluster. CoreWeave operates the runner; you deploy it on a specific cluster. Every runner carries exactly one policy, and a cluster hosts at most one runner, so this policy governs every sandbox on the cluster. The policy states what sandboxes may request and what they get by default. A policy must bound sandbox lifetime. The following example policy denies all outbound network access and caps sandboxes at one hour. Adjust it for your environment: widen allowedEgress to permit specific destinations, and raise the resource ceilings as needed. For every constraint group, see Configure a sandbox policy. Save it as policy.json:
policy.json
  1. Open the Clusters page in the cloud console.
  2. Select the cluster you want to deploy a runner on.
  3. In the Sandbox runner card, click Enable sandbox runner.
The card transitions through Pending to Ready. The runner then accepts sandbox requests.Set the policy afterward with cwic or curl, using one of the following tabs.
The runner is now deploying on the cluster. The next step confirms it’s ready before sending sandbox requests.

Run your first sandbox

Wait for the runner to reach the Ready state before you send sandbox requests:
  • Cloud console: Open the cluster’s Sandbox runner card and watch the status badge until it shows Ready.
  • cwic: Run cwic sandbox runner get [RUNNER-ID] and look for INSTALL to be READY. For a longer view, use cwic sandbox runner describe [RUNNER-ID].
  • curl: Poll the runner until installStatus is READY:
Once the runner is Ready, anyone in your organization with a CoreWeave API access token can create sandboxes against it. The remaining steps cover the researcher workflow: install the Python SDK, set an API token, and run a sandbox against the runner.
Placement defaults to serverless. Set placement_mode="cks" on every create, or the sandbox runs on CoreWeave-operated capacity instead of the runner you just deployed, and the policy you set doesn’t apply to it.
To install the SDK, run:
Generate a CoreWeave API access token from the Tokens page in the cloud console and copy the Token Secret value. For more information, see Manage API Access Tokens. Replace [API-ACCESS-TOKEN] with that value and set it as CWSANDBOX_API_KEY:
Run a sandbox that prints “Hello!” on the runner you deployed:
If the command succeeds, Hello! appears in the output. To target one specific runner rather than any CKS runner in your organization, pass runner_ids=["[RUNNER-ID]"] alongside placement_mode="cks". This example does the following:
  • Sandbox.run() creates a sandbox and returns it inside a context manager. The sandbox tears down on context exit.
  • exec() runs a command inside the sandbox and returns a Process object.
  • .result() waits for the command to complete and returns the output.
This example doesn’t set a lifetime, so the sandbox runs for at most 10 minutes before the platform terminates it. The default keeps a forgotten sandbox from running indefinitely. For anything longer, including a long-lived development sandbox, set max_lifetime_seconds explicitly when you create the sandbox:
You can’t extend the lifetime after a sandbox starts. For the full set of timeout settings, see Timeouts.
For more SDK patterns, see the Python client documentation. Notable guides include RL training, SWE-bench evaluation, and the sandbox lifecycle guide.

Disable the runner

When you no longer need sandboxes on the cluster, disable the runner. The runner is removed from the cluster and stops accepting sandbox requests. For a clean teardown, stop running sandboxes from the Python client before you disable the runner.
  1. Open the cluster’s Sandbox runner card.
  2. Click Disable sandbox runner and confirm.

Spill over between modes

When your organization can reach both serverless capacity and a CKS runner, spillover retries sandbox creation once in the alternate mode when the first mode can’t place the request, whether because of capacity, no suitable runner, an unavailable or overloaded runner, or an unsatisfied placement constraint. It’s a Python client option, available in cwsandbox 1.0.0 and later:
Use serverless_then_cks for the reverse order. Both directions have constraints:
  • cks_then_serverless requires placement_mode="cks" or an unset mode. An explicit placement_mode="serverless" raises ValueError.
  • serverless_then_cks requires placement_mode="serverless" or an unset mode, and can’t be combined with runner_ids.
  • Sandboxes created from a template accept only the default, strict, which honors placement_mode and never retries.

Next steps

The following resources cover next steps:
  • The Python client page introduces the SDK and links into reference material.
  • The Python client tutorial walks through configuration, command execution, file operations, and cleanup.
  • The Python client guides cover lifecycle, streaming, RL training, SWE-bench, SUNK integration, and other advanced topics.
Last modified on September 3, 2026