AsyncConnectorClient is the async-native client. Use it when your pipeline uses asyncio —
LangChain, LlamaIndex, FastAPI, or any framework where embedding and vector store calls are async.
Callbacks are async def coroutines, so you can await any async operation directly inside them.
Constructor
string
required
Full URL to
GET /stream/{product_id} on the connector.string
default:"\"\""
Unkey API key (
uk_live_...). Leave empty to connect without authentication.int
default:"4"
Maximum number of concurrent in-flight callback tasks per session. Each
session’s callbacks run as independent
asyncio.Task instances — a slow
LLM or vector store call for one session never delays delivery for another.
Increase this if a single session can generate bursts of events faster than
your callback can process them.Callbacks
All registration methods returnself for chaining.
.on_actions(fn)
async Callable[[ActionsPayload], None]
required
Async coroutine called every time a batch of UI actions arrives.
await any async I/O directly — it won’t block other coroutines..on_summary(fn)
async Callable[[SummaryPayload], None]
required
Async coroutine called every time a session summary arrives.
Per-session task isolation
Each incoming payload is dispatched as an independentasyncio.Task keyed by session_id. This means:
- A slow embedding call for session A never delays delivery for session B.
- Each session has its own
asyncio.Semaphorecapped atsession_concurrencyconcurrent tasks. - The SSE reader loop is never blocked by your callback logic.
asyncio.Task architecture.
Lifecycle
await .run()
Connect to the SSE stream and process events. Reconnects with exponential backoff (1 s → 30 s).
.run_in_background()
Schedule run() as an asyncio.Task and return immediately.
asyncio.Task.