Morph Cloud SDK
raw JSON → 0.1.111 verified Mon Apr 27 auth: no python
A Python SDK and CLI tool for creating, managing, and interacting with Morph Cloud VMs. Current version: 0.1.111. Rapid release cadence (daily/weekly).
pip install morphcloud Common errors
error morphcloud.exceptions.AuthenticationError: Invalid API key ↓
cause API key not set or incorrect.
fix
Check that MORPH_API_KEY environment variable is set and valid.
error morphcloud.exceptions.ResourceNotFoundError: VM with id '...' not found ↓
cause VM ID does not exist or has been destroyed.
fix
Verify the VM ID is correct. Use client.vms.list() to find active VMs.
Warnings
gotcha API key must be set via environment variable MORPH_API_KEY or passed as argument. The SDK does not fall back to config files. ↓
fix Set MORPH_API_KEY environment variable or pass api_key parameter to MorphCloudClient.
breaking VM image parameter does not accept image IDs from the dashboard. Use image names like 'ubuntu-22.04' or 'debian-11'. ↓
fix Use the exact image name from the SDK's list_images() method or the CLI.
Imports
- MorphCloudClient
from morphcloud import MorphCloudClient - morphcloud
import morphcloud
Quickstart
from morphcloud import MorphCloudClient
import os
client = MorphCloudClient(api_key=os.environ.get('MORPH_API_KEY', ''))
# Create a VM
vm = client.vms.create(name='my-vm', image='ubuntu-22.04')
print(f"VM ID: {vm.id}")
# Start the VM
vm.start()
# Execute a command
result = vm.exec('echo hello')
print(result.stdout)
# Stop and destroy
vm.stop()
vm.destroy()