Skip to main content

First Success (5–10 minutes)

This guide gets you to a working Morph Devbox (recommended) and your first successful command run.

Devboxes are the best fit for:

  • Development: VSCode/Cursor + tmux integration for CLI agents, plus fast branching for “many workspaces”
  • Prototyping: expose an interactive preview URL for a web app or API; optionally disable auto-sleep to behave like a persistent VPS
  • Sharing & collaboration: share a live devbox via URL inside your Morph Cloud organization

If you want finer-grained VM control and direct snapshot manipulation for advanced use cases (e.g. RL environments or test-time scaling), see the Infrastructure primitives flow below.

1) Install the SDK (or CLI)

Follow the SDK Installation guide.

2) Set your API key

Follow API Keys and export MORPH_API_KEY.

This is the smallest “end-to-end” Devboxes flow: create a devbox, run a command, and expose an HTTP preview URL.

# 1) Pick a template and start a devbox
morphcloud devbox template list
TEMPLATE_ID="<pick-a-template-id>"

DEVBOX_ID=$(
morphcloud devbox start "$TEMPLATE_ID" --json | jq -r '.id'
)
echo "Devbox: $DEVBOX_ID"

# 2) Run a command in your devbox (via SSH)
morphcloud devbox ssh "$DEVBOX_ID" echo "Hello from a Morph Devbox!"

# 3) Start a tiny web server (in the background) and expose it publicly
morphcloud devbox ssh "$DEVBOX_ID" bash -lc "nohup python3 -m http.server 3000 >/tmp/http.log 2>&1 &"

morphcloud devbox expose-http "$DEVBOX_ID" --name app --port 3000

4) Advanced: infrastructure primitives (instances + snapshots)

This is the VM primitives path. It’s great for power users who want direct control over VMs and snapshots.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

snapshot = client.snapshots.create(
image_id="morphvm-minimal",
vcpus=1,
memory=1024,
disk_size=10000,
)

instance = client.instances.start(snapshot_id=snapshot.id)
instance.wait_until_ready()

result = instance.exec(command="echo 'Hello, Morph Cloud!'")
print(result.stdout)

instance.stop()

Next steps