Skip to main content
Run Muse Code inside a CoreWeave sandbox to edit files and execute commands in a remote workspace. This guide uses the Sandbox software development kit (SDK) to install the command-line interface (CLI) and clone a repository. You then run a task without an interactive terminal and retrieve the result before you stop the sandbox. The agent process and workspace run on CoreWeave, and model requests go to Meta.
CoreWeave Serverless sandboxes are in public preview.

Prerequisites

Before you begin, you need the following:
  • A W&B API key. These examples select W&B authentication. For other credentials, see Choose a credential.
  • A Meta API key with access to Muse Code.
  • A public repository URL the sandbox can clone. Private repositories require Git credentials inside the sandbox.
  • Python 3.11 or later with uv, or Node.js 22 or later with npm.
Load your credentials from your secret manager into your local terminal environment. Replace [WANDB-API-KEY] with your W&B API key and [META-API-KEY] with your Meta API key:
The script passes the Meta key over standard input so it doesn’t appear in command arguments or sandbox configuration. For a shared team credential injected as an environment variable at sandbox creation, see W&B secrets.

Install the Sandbox client

Choose a language and prepare a local project:

Run a task in the sandbox

Save the script for your language using the filename shown. Each script creates a serverless sandbox with a 30-minute maximum lifetime and performs these steps:
  1. Installs Muse Code with Meta’s installer.
  2. Clones your repository into the /workspace/project directory.
  3. Runs muse exec to build and test a sparkline CLI that renders numbers as a small chart.
  4. Runs the generated CLI independently, checks its output, and saves the sparkline.mjs file locally.
  5. Stops the sandbox in a finally block, including when setup or execution fails.
These examples were tested with Muse Code 1.3.0. The installer can install a newer version, so each script runs muse --version after installation. The example uses --yolo to disable Muse Code’s approval prompts and operating system (OS) sandbox and trust the workspace for this run. CoreWeave supplies the outer sandbox. Muse can access files, credentials, and network destinations available inside that sandbox. Use a repository you trust and provide only the credentials the task needs. For more information, see Muse Code permissions.
run_muse.py
In your local project directory, replace [REPOSITORY-URL] with your public repository URL, then run the script:
After the installation and agent output, the script checks and prints the sparkline:
The script saves the generated sparkline.mjs file in your local project directory, then stops the sandbox. If the file already exists locally, the script overwrites it. The output check runs independently of Muse’s own test and verifies this example’s input. For a larger task, replace it with tests for your requirements. These examples don’t configure persistent storage. Copy the files you need out of the sandbox before the finally block runs. See file operations and file system snapshots.

Troubleshoot

Use these checks to resolve common issues:
  • If sandbox creation fails, check your W&B key and authentication settings.
  • If Muse Code reports an authentication error, check META_API_KEY and your Meta account setup. The sandbox credential doesn’t authenticate model requests.
  • If installation, cloning, or model requests fail, check outbound access to Meta and your Git host. These examples use serverless placement. To use your own CoreWeave Kubernetes Service (CKS) cluster, switch to a CoreWeave API access token and the client settings in Configure CKS placement and policy. Confirm that the runner’s policy grants egress to those destinations.
  • If a larger task times out, adjust the command timeout and sandbox lifetime before running it. The 30-minute lifetime includes startup and installation. See command timeouts and sandbox lifecycle.

Next steps

For more information, see these guides:
Last modified on September 23, 2026