Key Capabilities
The Streaming Retrieval API supports:- Real-time event streaming for RAG and agent operations.
 - Progressive response generation with token-level updates.
 - Immediate access to intermediate results such as retrieved documents or citations.
 - Fine-grained event structure to handle reasoning steps, tool calls, and responses.
 - Improved responsiveness for conversational and research-oriented applications.
 
Streaming Events
During streaming, R2R emits structured event types that represent each stage of the retrieval and generation process:| Event Type | Description | 
|---|---|
SearchResultsEvent | Contains initial search results from documents. | 
MessageEvent | Streams partial response tokens as they are generated. | 
CitationEvent | Indicates when a citation has been added to the response. | 
ThinkingEvent | Provides insight into the model’s internal reasoning steps (for agents). | 
ToolCallEvent | Indicates when the model invokes a tool during processing (for agents). | 
ToolResultEvent | Returns the results from previously called tools (for agents). | 
FinalAnswerEvent | Contains the complete generated answer with citations. | 
Streaming RAG
Basic Streaming RAG
To use streaming with basic RAG functionality:Streaming RAG with Web Search
To include web search in your streaming RAG:Streaming Agent
R2R provides powerful streaming agents that supports complex interactions with both document-based knowledge and web resources.Basic Streaming Agent
Advanced Research Agent with Tools
The R2R agent can leverage multiple tools to perform in-depth research:Streaming Citations
R2R streaming citations provide detailed attribution information that links specific parts of the response to source documents:id: Unique identifier for the citation.index: The display index (e.g., /[1], /[2]).start_indexandend_index: Character positions in the response.source_type: The type of source (chunk, graph, web).source_id: ID of the specific chunk/node.document_id: ID of the parent document.source_title: Title of the source document.