Skip to content

Python SDK

The Python SDK offers synchronous Sandbox and asynchronous AsyncSandbox surfaces.

import os
from axern_sdk import AxernClient, Sandbox
client = AxernClient.from_context(
os.path.expanduser("~/.config/axern/config.json")
)
with Sandbox(client=client, template_id="python311") as sandbox:
result = sandbox.exec(
"python -c \"print('hello from Python')\"",
text=True,
check=True,
)
print(result.stdout)
sandbox.write_text("/tmp/message.txt", "payload\n")
print(sandbox.read_text("/tmp/message.txt"))
client.close()

Use exec_stream() for incremental output and process() when you need stdin, termination, or explicit wait behavior. Directory transfer is archive-backed and rejects unsafe paths and links.