papermap-air; the Python import is air. Python
3.10 or newer is required and the SDK is async-native.
AirClient
await client.aclose() explicitly.
client.runs.create()
Creates a run. agent_id is required. model_id, input, context, and
webhook_url are optional. Returns a Run.
client.runs.get(run_id)
Returns the latest state of a run.
client.runs.wait(run_id, timeout=60, poll_interval=0.2)
Polls until succeeded, failed, or cancelled. Raises RunTimeoutError when
the local timeout is reached.
client.runs.stream(run_id, *, after_seq=0, max_retries=3, retry_delay=0.5)
Returns an async iterator of RunEvent objects. It emits existing events after
after_seq, continues with live events, and stops after a terminal
run_succeeded, run_failed, or run_cancelled event.
The SDK reconnects after a temporary stream failure and resumes after the last
sequence number it received. max_retries controls the number of reconnect
attempts and retry_delay controls the delay between them.
client.runs.cancel(run_id)
Requests cancellation and returns the server response dictionary.
Run
RunEvent
When
type is model_output_reset, discard any partial model text already
rendered. This event means AIR started another model attempt after a retry or
fallback. Terminal run events end the iterator.
@tool
context parameter receives the
run context. Every tool must return a dictionary.
Use a separate ToolRegistry when you want explicit isolation instead of the
process-wide default registry.
Worker
start(), poll_once(), heartbeat(), run(),
mount_mcp(), and aclose().
Errors
All SDK errors inherit fromAirError:
AirProtocolErrorfor rejected or unexpected HTTP responsesRunTimeoutErrorwhen a local wait deadline expiresToolDefinitionErrorfor invalid or duplicate tool definitionsToolResultErrorwhen a tool does not return a dictionaryMcpErrorfor MCP transport or protocol failures

