Run Claude Code in a sandbox

Preview

Run Claude Code in a sandbox with an Anthropic API key, a Claude subscription, or the open models of Munito AI.

Sign in

Use one of these three methods.

With an Anthropic API key

Put the key in the env of the sandbox:

{
  "ANTHROPIC_API_KEY": "sk-ant-..."
}

Anthropic bills the usage to this key. See authentication.

With a Claude subscription

  1. Connect to the sandbox over SSH.
  2. Run claude.
  3. Type /login, and select your Claude account.
  4. Open the link on a device, and sign in with your Pro or Max plan.
  5. Paste the code into the terminal.
  • The sign-in stays in the sandbox. Each later claude -p command uses it.
  • Claude Code uses the usage limits of your plan.
  • A plan is for the work of one person. For many agents, use an API key.
  • Anthropic does not let a third party collect or store the tokens of a Claude account (legal and compliance). Do not put a token in an API request.

With the open models of Munito AI

Put these variables in the env of the sandbox:

{
  "ANTHROPIC_BASE_URL": "https://api.munito.ai/inference",
  "ANTHROPIC_AUTH_TOKEN": "munitoai_...",
  "ANTHROPIC_MODEL": "zai-org/glm-5.3-flash[1m]",
  "ANTHROPIC_DEFAULT_OPUS_MODEL": "zai-org/glm-5.3-flash[1m]",
  "ANTHROPIC_DEFAULT_SONNET_MODEL": "zai-org/glm-5.3-flash[1m]",
  "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen/qwen3.8-27b"
}
  • Use a Munito AI key with the Inference permission. The same key opens the sandboxes API.
  • Claude Code with open models explains each variable, the models and the regional hosts.

Run a task

curl -sS --fail-with-body "https://api.munito.ai/sandboxes/v1/sandboxes/$SANDBOX/exec" \
  -H "Authorization: Bearer $MUNITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "cd /workspace && claude -p \"Write a Python script that prints the first 10 primes, and run it\" --allowedTools Bash Edit Write Read --output-format json", "timeout": 1800}'
  • claude -p runs one task, and then it stops.
  • --allowedTools Bash Edit Write Read lets Claude Code run commands and change files with no question.
  • As root, Claude Code refuses --dangerously-skip-permissions. Use --allowedTools.
  • --output-format json gives the result and the session_id.
  • To get each event during the task, use --output-format stream-json --verbose and "stream": true.
  • To continue a session, add --resume <session_id> to a later command.
  • For a task of more than 30 minutes, start Claude Code in the background, and read its log with later commands:
nohup claude -p "..." --allowedTools Bash Edit Write Read > /workspace/claude.log 2>&1 &

Use the terminal UI

  1. Add your public key with SSH.
  2. Connect with the command that GET /sandboxes/{sandbox_id}/ssh gives.
  3. Run claude. The shell starts in /workspace, with the variables of the sandbox.

To keep the session after you disconnect, install tmux (apt-get install -y tmux), and start Claude Code in it.