Skip to main content
Perform a basic vector search:
dict
The search results from the R2R system.
str
required
The search query.
Optional[Union[VectorSearchSettings, dict]]
default:"None"
Optional settings for vector search, either a dictionary, a VectorSearchSettings object, or None may be passed. If a dictionary or None is passed, then R2R will use server-side defaults for non-specified fields.
Optional[Union[KGSearchSettings, dict]]
default:"None"
Optional settings for knowledge graph search, either a dictionary, a KGSearchSettings object, or None may be passed. If a dictionary or None is passed, then R2R will use server-side defaults for non-specified fields.

Search custom settings

Learn more about the search API here. It allows searching with custom settings, such as bespoke document filters and larger search limits:
Learn more about the dedicated knowledge graph capabilities in R2R here. Combine traditional keyword-based search with vector search:
Learn more about the dedicated knowledge graph capabilities in R2R here. You can utilize knowledge graph capabilities to enhance search results, as shown below:
dict
The knowledge graph search results from the R2R system.

Retrieval-Augmented Generation (RAG)

Basic RAG

Generate a response using RAG:
dict
The RAG response from the R2R system.
str
required
The query for RAG.
Optional[Union[VectorSearchSettings, dict]]
default:"None"
Optional settings for vector search, either a dictionary, a VectorSearchSettings object, or None may be passed. If a dictionary is used, non-specified fields will use the server-side default.
Optional[Union[KGSearchSettings, dict]]
default:"None"
Optional settings for knowledge graph search, either a dictionary, a KGSearchSettings object, or None may be passed. If a dictionary or None is passed, then R2R will use server-side defaults for non-specified fields.
Optional[Union[GenerationConfig, dict]]
default:"None"
Optional configuration for LLM to use during RAG generation, including model selection and parameters. Will default to values specified in r2r.toml.
Optional[str]
default:"None"
Optional custom prompt to override the default task prompt.
Optional[bool]
default:"True"
Augment document chunks with their respective document titles?

RAG with custom search settings

Learn more about the RAG API here. It allows performing RAG with custom settings, such as hybrid search:

RAG with custom completion LLM

R2R supports configuration on server-side and at runtime, which you can read about here. An example below, using Anthropic at runtime:

Streaming RAG

R2R supports streaming RAG responses for real-time applications:
Generator

Advanced RAG Techniques

R2R supports advanced Retrieval-Augmented Generation (RAG) techniques that can be easily configured at runtime. These techniques include Hypothetical Document Embeddings (HyDE) and RAG-Fusion, which can significantly enhance the quality and relevance of retrieved information. To use an advanced RAG technique, you can specify the search_strategy parameter in your vector search settings:
For a comprehensive guide on implementing and optimizing advanced RAG techniques in R2R, including HyDE and RAG-Fusion, please refer to our Advanced RAG Cookbook.

Customizing RAG

Putting everything together for highly customized RAG functionality at runtime:

Agents

Multi-turn agentic RAG

The R2R application includes agents which come equipped with a search tool, enabling them to perform RAG. Using the R2R Agent for multi-turn conversations:
Note that any of the customization seen in AI powered search and RAG documentation above can be applied here.
Object
The agent endpoint will return the entire conversation as a response, including internal tool calls.
list[Messages]
required
The list of messages to pass the RAG agent.
Optional[Union[VectorSearchSettings, dict]]
default:"None"
Optional settings for vector search, either a dictionary, a VectorSearchSettings object, or None may be passed. If a dictionary is used, non-specified fields will use the server-side default.
Optional[Union[KGSearchSettings, dict]]
default:"None"
Optional settings for knowledge graph search, either a dictionary, a KGSearchSettings object, or None may be passed. If a dictionary or None is passed, then R2R will use server-side defaults for non-specified fields.
Optional[Union[GenerationConfig, dict]]
default:"None"
Optional configuration for LLM to use during RAG generation, including model selection and parameters. Will default to values specified in r2r.toml.
Optional[str]
default:"None"
Optional custom prompt to override the default task prompt.

Multi-turn agentic RAG with streaming

The response from the RAG agent may be streamed directly back
Generator
The agent endpoint will stream back its response, including internal tool calls.