Quickstart
InstaVM provides infrastructure for AI agents to execute code in isolated sandboxes. This guide gets you running code in under 5 minutes.
Get your API key
- Sign up at the InstaVM Dashboard
- Navigate to API Keys
- Create a new key (starts with
sk_instavm_...)
Install the SDK
- Python
- TypeScript
pip install instavm
npm install instavm
Run your first code
- Python
- TypeScript
from instavm import InstaVM
with InstaVM('your_api_key') as vm:
result = vm.execute("print('Hello from InstaVM')")
print(result['output'])
import { InstaVM } from 'instavm';
const client = new InstaVM('your_api_key');
const result = await client.execute("print('Hello from InstaVM')");
console.log(result.output);
await client.dispose();
That is it. InstaVM boots a microVM, runs your code inside it, and returns the output. The VM is destroyed when the session ends.
Choose your path
AI agent builders
Give your LLM a code execution tool in 5 lines:
from instavm import InstaVM
import json
vm = InstaVM("your_api_key")
def execute_code(code: str) -> str:
"""Tool function for OpenAI function calling."""
result = vm.execute(code)
return result.get("output", "")
Register execute_code as a tool with OpenAI, Anthropic, or any LLM that supports function calling. The sandbox isolates untrusted LLM-generated code from your infrastructure.
Next: Build an AI Agent Code Execution Tool
Code interpreter builders
Build a ChatGPT-style code interpreter with persistent sessions:
from instavm import InstaVM
vm = InstaVM("your_api_key")
# State persists between execute() calls
vm.execute("import pandas as pd; df = pd.DataFrame({'x': [1,2,3]})")
result = vm.execute("print(df.describe())")
print(result['output'])
Variables, files, and installed packages carry over between calls within the same session.
Next: Build a Code Interpreter
Deploy and share
Spin up a web server and get a public URL:
from instavm import InstaVM
vm = InstaVM("your_api_key")
vm.execute("""
import subprocess, sys
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'flask'])
""")
vm.execute_async("""
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '<h1>Running on InstaVM</h1>'
app.run(host='0.0.0.0', port=8080)
""")
share = vm.shares.create(port=8080, is_public=True)
print(f"Live at: {share.get('public_url')}")
Next: Deploy a Web App
Next steps
- How It Works -- architecture and security model
- Core Concepts -- sandboxes, sessions, snapshots, egress
- Python SDK Reference -- full SDK documentation
- TypeScript SDK Reference -- TypeScript client
- REST API Reference -- direct API access