Python SDK
The InstaVM Python SDK provides a client for executing code, managing VMs, and automating browsers on the InstaVM platform.
Installation
pip install instavm
Current version: 0.11.0
Quick start
from instavm import InstaVM
with InstaVM('your_api_key') as vm:
result = vm.execute("print('Hello from InstaVM')")
print(result['output'])
Three lines: create a client, execute code, read the output. The context manager kills the VM when the block exits.
Client configuration
from instavm import InstaVM
client = InstaVM(
api_key='your_api_key',
base_url='https://api.instavm.io',
timeout=300,
max_retries=0,
cpu_count=2,
memory_mb=512,
env={"MY_VAR": "value"},
metadata={"project": "my-project"}
)
Using environment variables
import os
from instavm import InstaVM
client = InstaVM(os.getenv('INSTAVM_API_KEY'))
Configuration options
| Parameter | Default | Description |
|---|---|---|
api_key | Required | Your InstaVM API key |
base_url | https://api.instavm.io | API endpoint URL |
timeout | 300 | Request timeout in seconds |
max_retries | 0 | Retry attempts for failed requests |
cpu_count | 2 | vCPUs to allocate |
memory_mb | 512 | Memory in MB to allocate |
env | {} | Environment variables to inject into the VM |
metadata | {} | Custom metadata for filtering and labeling |
SDK sections
- Code Execution --
execute(),execute_async() - Session Management -- context managers,
kill(), session info - File Operations --
upload_file(),download_file() - VM Management -- create, list, update, delete, clone, snapshot VMs
- Snapshots -- list, create, get, delete snapshots
- Browser Automation -- headless browser sessions
- Egress & Networking -- egress policies, shares, SSH keys
- Platform APIs -- computer use, API keys, audit logs, webhooks
- Error Handling -- exception types and patterns