How to run a CodeSandbox sandbox (via web, CLI, API, or AI agent)

Connect your CodeSandbox key once, then create CodeSandbox sandboxes from the ComputeSDK dashboard, one CLI command, an AI agent, the API, or the SDK.

David Tice

Head of Product ·

CodeSandbox is a cloud development platform that enables instant, collaborative coding environments. It provides sandboxed environments for web development with support for modern frameworks, allowing teams to prototype, share, and iterate on code directly in the browser.

ComputeSDK runs CodeSandbox sandboxes on your own CodeSandbox account. Connect your CodeSandbox key to ComputeSDK once, and you can create a CodeSandbox sandbox from the dashboard, your terminal, an AI agent, a REST call, or a few lines of TypeScript, with no CodeSandbox SDK or credentials in your code.

  • Dashboard: open Sandboxes → New sandbox and pick CodeSandbox.
  • CLI: run npm create codesandbox or compute new codesandbox.
  • MCP: connect Claude, ChatGPT, or another agent to https://platform.computesdk.com/mcp.
  • REST API: call POST /api/v1/sandboxes from any language.
  • SDK: import { compute } from 'computesdk' in a TypeScript app.

How CodeSandbox performs

ComputeSDK benchmarks CodeSandbox alongside every other sandbox provider on the same hardware and schedule. Its current results, as of November 20, 2026:

See every result on the CodeSandbox provider page. Browse the burst TTI, DAX and reliability leaderboards.

Popular comparisons: CodeSandbox vs Sail, CodeSandbox vs Agent37, CodeSandbox vs Superserve.

Before you start

Create an account at platform.computesdk.com with Google, GitHub, or email. Your account comes with an organization, and every sandbox you create belongs to it.

CodeSandbox sandboxes run on your own CodeSandbox account, so add your key first:

  1. Open Settings → BYOK on the platform.
  2. Add your CodeSandbox credentials and save.

CodeSandbox bills you directly for the compute.

1. Create a sandbox in the dashboard

  1. Sign in to platform.computesdk.com and open Sandboxes in the sidebar.
  2. Click New sandbox.
  3. Under Size, pick how much CPU and memory you want.
  4. Under Routing, pick CodeSandbox.
  5. Click Create sandbox.

The New sandbox form on the ComputeSDK dashboard, with Size and Routing selected (shown with Vercel; the steps are the same for CodeSandbox)

The new sandbox appears in the Sandboxes list, and you can destroy it from there when you're done.

2. Create a sandbox from the CLI

The fastest way from a terminal is the CodeSandbox starter:

npm create codesandbox

It offers to install the compute CLI if you don't have it, then runs compute new codesandbox for you. The first time, it opens your browser so you can sign in to ComputeSDK and pick your organization. After that, the sandbox is created and ready.

Running npm create vercel creates a sandbox through ComputeSDK (shown with Vercel; the steps are the same for CodeSandbox)

If you already have the CLI, you can do the same in one command:

npm install -g @computesdk/cli
compute new codesandbox

If you aren't signed in yet, compute new opens the browser sign-in first (you can also run compute login yourself). The new sandbox becomes the current sandbox for your directory, so the next commands don't need its ID:

compute exec echo hello   # run a command
compute list              # see your sandboxes
compute destroy           # stop it and stop billing

compute new creates a sandbox and prints how to use it (shown with Vercel; the steps are the same for CodeSandbox)

Run compute new codesandbox . to also copy your current project into the sandbox at /app.

3. Let an AI agent create it over MCP

ComputeSDK has a remote MCP server, so an AI agent can create and use sandboxes for you. Connect it to your agent:

  • Claude (web and desktop): go to Settings → Connectors → Add custom connector and enter https://platform.computesdk.com/mcp, or add ComputeSDK Router from the connectors directory.
  • Claude Code: run claude mcp add --transport http computesdk https://platform.computesdk.com/mcp.
  • ChatGPT: install the ComputeSDK Router app from the ChatGPT apps directory.
  • Any other MCP client: point it at https://platform.computesdk.com/mcp.

The first time the agent uses a tool, a ComputeSDK sign-in opens in your browser. Sign in with OAuth, choose the organization the agent should use, and approve the permissions. That's it. Now ask for what you want:

Create a CodeSandbox sandbox, run node -v in it, and destroy it when you're done.

The agent creates the sandbox, runs commands, reads and writes files, starts servers, and shares a public preview URL for a port, all through ComputeSDK. Nothing runs on your computer. To disconnect, remove the app under Settings → Connected Apps.

4. Create a sandbox with the REST API

For direct calls from any language, use an organization API key:

  1. Sign in to the platform and open Settings → API Keys.
  2. Create a key and copy it. It is shown only once.
  3. Export it in your shell:
export COMPUTE_API_KEY="your_org_api_key"

Create a CodeSandbox sandbox:

curl https://platform.computesdk.com/api/v1/sandboxes \
  -H "Authorization: Bearer $COMPUTE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"only":["codesandbox"],"byok":"only"}'

only limits this create to CodeSandbox, and byok: "only" tells it to use your own key. The response's sandbox.id is what you use in the next calls. Run a command, then destroy the sandbox:

curl https://platform.computesdk.com/api/v1/sandboxes/$SANDBOX_ID/commands \
  -H "Authorization: Bearer $COMPUTE_API_KEY" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"command":"echo hello"}'
 
curl -X DELETE https://platform.computesdk.com/api/v1/sandboxes/$SANDBOX_ID \
  -H "Authorization: Bearer $COMPUTE_API_KEY"

Creating a sandbox and running a command with curl (shown with Vercel; the steps are the same for CodeSandbox)

The same API also handles files, background processes, and preview URLs. See the API reference.

5. Create a sandbox with the SDK

In a TypeScript or JavaScript app, install the SDK and use the same API key:

npm install computesdk
export COMPUTE_API_KEY="your_org_api_key"
import { compute } from 'computesdk';
 
const sandbox = await compute.instances.create({
  providerOrder: ['codesandbox'], // your own CodeSandbox key, no fallback
  size: 'small',
});
try {
  const result = await sandbox.runCommand('echo hello');
  console.log(result.stdout);
} finally {
  await sandbox.destroy();
}

Importing computesdk is all it takes: the SDK reads COMPUTE_API_KEY and talks to the platform, so there is no CodeSandbox package or CodeSandbox credential in your app. providerOrder: ['codesandbox'] keeps the create on your own CodeSandbox key, with no fallback to another provider. Without it, compute.instances.create() follows your organization's saved routing under Settings → Sandboxes.

Creating a sandbox with the computesdk package

Bring your own key: try it first, or as a fallback

Your CodeSandbox key also works alongside ComputeSDK's managed accounts on other providers, so you decide what runs where.

  1. Add your key under Settings → BYOK.
  2. Open Settings → Sandboxes and set Use BYOK accounts:
  • First: try your own keys first, then ComputeSDK's managed accounts.
  • Fallback: use managed accounts first, then fall back to your own keys.
  • Only: use only your own keys.
  • Off: use only managed accounts.

The Use BYOK accounts setting under Settings → Sandboxes

The setting applies everywhere: the dashboard, CLI, MCP, API, and SDK. From the API, set it with PATCH /api/v1/sandboxes/routing and {"byok":"first"}, or pass byok on a single create.

Next steps

Frequently asked questions

Do I need a CodeSandbox account to run a CodeSandbox sandbox?

Yes. CodeSandbox sandboxes on ComputeSDK run on your own CodeSandbox account. Add your CodeSandbox key under Settings → BYOK, then create sandboxes from the dashboard, CLI, MCP, API, or SDK.

How do I create a CodeSandbox sandbox from the terminal?

Run npm create codesandbox or compute new codesandbox. The first time, the CLI opens your browser so you can sign in to ComputeSDK. Then run commands with compute exec and clean up with compute destroy.

Can an AI agent create CodeSandbox sandboxes?

Yes. Connect Claude, ChatGPT, or another MCP client to https://platform.computesdk.com/mcp and sign in with OAuth. The agent can then create a CodeSandbox sandbox, run commands, edit files, and destroy it.

Get new posts by email

Questions or thoughts on this post?

Join the conversation on X