StreamingResponse wraps a Server-Sent Events (SSE) stream and yields content tokens as they arrive from the backend. It is returned by client.query(..., stream=True).
Basic usage
Accessing metadata
Metadata (sources, fact counts, entities) is populated during iteration and available after the stream completes:Properties
to_dict()
Convert the completed stream into a dict matching the non-streaming response format:Context manager
StreamingResponse supports the context manager protocol for explicit cleanup:
SSE event types
The stream delivers these event types internally:
You do not need to handle these directly —
StreamingResponse processes them and exposes the data through properties.