Apie (sync)
Use for scripts, Flask handlers, Celery tasks, and any synchronous code.__init__ when enabled. ready() blocks until complete.
AsyncApie (async)
Use for FastAPI, asyncio agents, and any async code.await ready() before instrumenting.
Async helper convention
Every integration helper has an*_async variant:
Context propagation
| Client | run_context | Auto runId in MCP client? |
|---|---|---|
Apie (sync) | Sets contextvars | Yes — create_instrumented_mcp_client reads context |
AsyncApie | Does not set contextvars | No — pass runId explicitly |
Context managers
Sync-only context managers:AsyncApie uses with_tool and with_guard (async callbacks) but not async context managers.
Blocking approval waits
apie.approvals.wait() blocks the calling thread (sync) or awaits (async). Set approval_timeout_ms appropriately for long-running agents.
Config with pre-built client
apie.config.py can export a pre-built instance:
Next steps
Connect your first agent
Setup with sync and async examples.
Instrumented MCP client
MCP context requirements.
