Skip to main content

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

ParameterDefaultDescription
api_keyRequiredYour InstaVM API key
base_urlhttps://api.instavm.ioAPI endpoint URL
timeout300Request timeout in seconds
max_retries0Retry attempts for failed requests
cpu_count2vCPUs to allocate
memory_mb512Memory in MB to allocate
env{}Environment variables to inject into the VM
metadata{}Custom metadata for filtering and labeling

SDK sections