Python SDK for Pyro — the open-source sandbox platform for AI agents.
pip install pyrovm-sdkimport asyncio
from pyro_sdk import Pyro
async def main():
pyro = Pyro(api_key="pk_...", base_url="http://localhost:8080")
async with await pyro.sandbox.create(image="python") as sb:
result = await sb.run("print('Hello from Pyro!')")
print(result.stdout) # "Hello from Pyro!\n"
asyncio.run(main())| Env var | Description |
|---|---|
PYRO_API_KEY |
API key (or pass api_key= to constructor) |
PYRO_BASE_URL |
Server URL (default: http://localhost:8080) |
Create a client. Reads from env vars if not provided.
Create a sandbox. Returns a Sandbox object.
Run code. Auto-detects language from image name.
Execute a command. Returns ExecResult(exit_code, stdout, stderr).
Write a file into the sandbox.
Read a file from the sandbox. Returns bytes.
Destroy the sandbox. Called automatically when using async with.
Register a base image once (idempotent), then boot sandboxes from it:
import asyncio
from pyro_sdk import Pyro
async def main():
pyro = Pyro(api_key="pk_...", base_url="http://localhost:8080")
# Idempotent: pulls if missing, attaches to in-flight pulls,
# returns immediately if already ready.
img = await pyro.images.ensure(name="py312", source="python:3.12")
print(img.name, img.status, img.digest)
async with await pyro.sandbox.create(image="py312") as sb:
result = await sb.run("print('Hello from py312!')")
print(result.stdout)
asyncio.run(main())Idempotent register. Same source → no-op. Different source → ImageConflictError.
Block until the pull settles. Failures raise ImageRegistrationError.
Kick off a pull, return a PullOperation. Use await op.wait(timeout=...) later.
Return current ImageInfo. 404 → ImageNotFoundError.