stream_events method opens a server-sent event (SSE) connection and yields TaskLifecycleEvent Pydantic models as they arrive. Pass a StreamOptions instance to filter by event type, set a heartbeat interval, and resume from a cursor after reconnection.
Basic usage
async for loop runs until the server closes the stream or an error is raised. Each event is a validated TaskLifecycleEvent with id, type, and data fields.
Reconnect with a cursor
After a disconnect, pass the last received event ID ascursor to resume the stream without missing events:
Event types
StreamOptions fields
Required scope
Streaming events requires theevents:read scope on your API key. A missing scope raises an InsufficientScopeError before the stream opens..png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)