Sandboxes

Preview

Start a Linux microVM for your code, run commands in it, and read and write its files.

Sandboxes are in public preview. Create a key in the console and start. The API, the limits and the prices can change before general availability.

A sandbox is a Linux microVM. It has its own kernel, disk and network. Code in one sandbox cannot reach another sandbox, unless both are in a network that you make.

Use a sandbox for:

  • Code that you do not trust, such as code that an AI agent writes.
  • A test or a build that must start clean.
  • An agent that needs its own computer. See Cloud Agents.
Value
Base URLhttps://api.munito.ai/sandboxes/v1
Key variableMUNITO_API_KEY
Templatesbase (Debian), ubuntu (Ubuntu with Docker) and desktop. See Templates
Work folder/workspace. Each command starts there, unless you set cwd

Without code

Sandboxes in the console starts a sandbox, shows its SSH command, opens a port in a browser and terminates it. The API does the rest.

Install the CLI

npm install -g @munitoai/cli
munito login

munito login asks for a key with the Inference permission, from the console. See the command line tool. Every step below also shows the API call underneath it, for a program or a CI system that takes no tool.

Quick start

1. Create a sandbox

munito create --size small --timeout 600

The sandbox uses the base template. Internet access and other optional features default to off. Pass --internet for outbound connections, and --size tiny for one vCPU and 128 MiB, restored from a prepared snapshot.

Keep the id it prints for the next steps:

export SANDBOX="sbx_01k8f6x7g3d2b9v5n4m1q0w8e6"

2. Run a command

munito exec $SANDBOX "python3 -c 'print(6 * 7)'"

munito run "<command>" does the same in a throwaway sandbox: it creates one, runs the command, prints the output and deletes the machine.

  • A string runs in bash -lc. A list, such as ["python3", "-V"], is the argument vector.
  • To get events while the command runs, set "stream": true. The API sends NDJSON: stdout and stderr events, then one exit event.
  • To create a sandbox and run a command in one request, set command in the create. The answer gives the result in command. This command runs for 60 seconds or less.

3. Write, read and list files

curl -sS --fail-with-body -X PUT \
  "https://api.munito.ai/sandboxes/v1/sandboxes/$SANDBOX/files/content?path=/workspace/hello.py" \
  -H "Authorization: Bearer $MUNITO_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  --data-binary 'print("Hello from the sandbox")'

curl -sS --fail-with-body \
  "https://api.munito.ai/sandboxes/v1/sandboxes/$SANDBOX/files/content?path=/workspace/hello.py" \
  -H "Authorization: Bearer $MUNITO_API_KEY"

curl -sS --fail-with-body \
  "https://api.munito.ai/sandboxes/v1/sandboxes/$SANDBOX/files?path=/workspace" \
  -H "Authorization: Bearer $MUNITO_API_KEY"

A write creates the parent folders. It replaces a file that exists.

4. Find your sandboxes again

munito ls

metadata holds your own keys and values. Tag each sandbox at its create, and one key finds the sandboxes of one customer, one job or one run. Pass each pair as key=value to GET /sandboxes, and the answer keeps the sandboxes that hold them all:

5. Delete the sandbox

munito rm $SANDBOX

The sandbox stops at once, and its files are deleted. GET /sandboxes/{sandbox_id} still shows the sandbox, with the status stopped.

Report abuse

The ports and SSH of the sandboxes have addresses under munito.run, such as https://8080-<id>.munito.run. The code at these addresses belongs to the customers of Munito AI.

To report phishing, malware or other abuse at such an address, send its full URL to security@munito.ai.