Skip to main content
Install the Python SDK and use a project-scoped app key:

Create and wait

input is the task sent to the agent. context carries trusted application data such as a tenant ID; AIR passes it to tools that declare a context parameter. webhook_url is optional.

Consume structured output

When the active agent version has an output schema, Run.output is the parsed, validated object described by that schema:
When the agent version has no output schema, the response remains free-form text and is returned as result.output["text"].
Treat a terminal Run.output or run_succeeded event as authoritative. Streaming model deltas are provisional text; for structured runs they contain the JSON response while it is still being generated and has not yet passed final validation.

Stream output as it is generated

Use stream() when a UI or CLI should show the model response before the run finishes:
The async iterator ends when the run succeeds, fails, or is cancelled. Each RunEvent includes seq, type, data, and created_at. If the connection drops, the SDK reconnects and requests events after the last sequence number, so missed output is replayed rather than skipped. Use after_seq when you persist the last processed sequence number yourself:
After streaming, read the Run with get() when you need the authoritative final status, validated structured output, error, or cost.

Read or cancel

The returned Run exposes id, status, output, error, cost_usd, and the complete response as raw.

Inspect the same run visually

Open Runs in the console to inspect the event sequence, model request and response, token usage, cost, and configuration snapshot.
AIR run trace showing a successful model response and usage metadata

The console trace for a run created through the same public API used by the SDK.

Handle errors

Treat context as security-sensitive input. A tool must still verify that every requested record belongs to the supplied tenant before reading or changing data.