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
str
The complete generated text, accumulated from all content deltas.
Optional[str]
Conversation session ID, if conversation context was maintained.
Dict[str, Any]
Full metadata dict from the backend.
List[Dict[str, Any]]
Source documents referenced in the answer.
List[str]
Reasoning chain steps (populated in
thinking and research modes).List[str]
Entities identified in the query and used for graph traversal.
int
Number of knowledge graph facts used to generate the answer.
int
Number of vector search chunks used.
Optional[str]
The LLM model that generated the response.
Optional[str]
Time spent on retrieval (graph + vector search).
Optional[str]
Error message if the stream encountered an error.
bool
True if the knowledge base had no relevant facts for the query.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.