Python SDK
The Python SDK for Pod, with a blocking client and an asyncio one
mapier-pod needs Python 3.13 or later. Import it as mapier_pod. Pod is the blocking client and AsyncPod the asyncio one, with the same calls.
Not available yet The TypeScript and Python packages are not published to their registries yet. Invited teams get them from us.
pip install mapier-podfrom mapier_pod import Pod
with Pod() as pod: # reads POD_API_KEY, or pass api_key= and base_url=
sandbox = pod.sandboxes.create(size="small", labels={"app": "quickstart"})
print(sandbox.run("uname -a && ls /").stdout)
sandbox.files.write("/root/hello.py", 'print("hello from Pod")\n')
result = sandbox.run(["python3", "/root/hello.py"])
print(result.exit_code, result.stdout)
sandbox.delete()With asyncio:
from mapier_pod import AsyncPod
async with AsyncPod() as pod:
sandbox = await pod.sandboxes.create(size="small")
print((await sandbox.run("uname -a")).stdout)
await sandbox.delete()base_url defaults to https://api.pod.mapier.ai, or POD_API_URL when it is set.
What it covers
- Sandboxes.
pod.sandboxes.create,get,listanddelete, andsleep,wake,stop,start,resize,extend,forkandsnapshot, onpod.sandboxesby id or on aSandbox. Calls that change a sandbox wait until the change is done, up totimeout. - Lists fetch the next page as you iterate:
for s in pod.sandboxes.list(state="running"), orasync foronAsyncPod..pages()gives the pages,.to_list()collects them. - Commands.
sandbox.exec(cmd)answers a handle whosestdoutandstderryield bytes as they arrive, withwait(),kill(signal),write_stdin,close_stdin,resizeandsend_signal.sandbox.run(cmd)collects the output;input=feeds standard input. A string runs under/bin/sh -c; a list runs as it is. A non-zero exit is not an error: checkresult.ok. - Files.
sandbox.files.read,read_text,write,list,remove,moveandmkdir. - Usage.
pod.usage.get(period="2026-11", group_by="size"), in seconds and bytes. - Your users.
pod.end_users.create,get,listandset_limits, andpod.end_users.sandbox(ref)for one computer per user; see Your users. - Organizations.
pod.organisations, withmembersandinvitations. Changing members is for a signed-in person, so with an API key those calls raiseperson_required. - Also
pod.snapshots,pod.operations,pod.keys,pod.projects,pod.service_grants,pod.billingandpod.catalog().pod.apisends any call by its operationId (pod.api.json("getSandbox", path={"sandbox_id": sid})), for anything the SDK does not wrap.
import sys
with sandbox.exec("npm test", cwd="/work", timeout_s=600) as proc:
for chunk in proc.stdout:
sys.stdout.buffer.write(chunk)
print(proc.wait().exit_code)Requests are the API's own: keyword arguments are checked by your type checker against the TypedDicts in mapier_pod.models, and answers are plain dicts typed by them. class is a Python keyword, so pass a typed dict for it: request: models.CreateSandboxRequest = {"size": "ci-2", "class": "ci"}, then create(**request).
Computer-use models
Not available yet Seeing and acting on a sandbox's screen is not offered yet. Commands, files and ports work today.
A computer-use model writes screen actions in its own form. mapier_pod.dialects turns one model action into Pod's screen actions, for OpenAI's computer-use tool (from_openai), Anthropic's computer tool (from_anthropic) and Gemini's computer-use calls (from_gemini, which needs the screen's width and height). Send what it answers with sandbox.screen.act:
from mapier_pod import dialects
result = dialects.convert("anthropic", tool_use.input)
sandbox.screen.act(result.actions, screenshot=result.screenshot or True)A conversion it cannot make raises ScreenDialectError, which names the dialect, the action and the field, never what the action typed.
Errors and retries
Every refusal is a PodApiError whose code is a name from the error list, with status, request_id, retry_after_s and is_retryable(). The others are PodConnectionError, PodTimeoutError, PodStateError, PodStreamError and PodValidationError, all subclasses of PodError.
The SDK sends a call again by itself only when the error list allows it and the call is a read or carries an idempotency key. Every call that changes something carries one, the same on every attempt. Pass idempotency_key= to repeat a call safely from another process; set retry=RetryPolicy(max_retries=…) on the client, or max_retries= on one call. Every call takes timeout, in seconds, for the whole call, retries and waiting included.
Stream tickets
A page should never hold your key. Your server asks for a single-use ticket bound to one command's stream and to the page's origin, and hands only the ticket to the page:
proc = sandbox.exec("npm test", detached=True)
ticket = sandbox.exec_stream_ticket(proc.id, origin="https://app.example.com", ttl_s=30)
return {"stream_url": ticket["stream_url"], "ticket": ticket["ticket"]} # to your page; never log itThe page opens new WebSocket(stream_url, ["pod.stream.v1", ticket]). A process with no key can attach the same way with attach_exec(ticket, base_url=...). The SDK never puts a ticket or a key in an error, a traceback or a log.