5.6K+ Star! R2R: An AI retrieval system supporting RAG

Exploring new breakthroughs in AI retrieval systems, R2R achieves efficient knowledge management and intelligent question and answer.
Core content:
1. Introduction to the R2R system and the RAG functions it supports
2. System features: multimodal content ingestion, hybrid search, knowledge graph and intelligent RAG
3. Application scenarios and usage guide: cloud service options, self-hosting and API installation settings
About R2R
R2R [1] (Reason to Retrieve) is an advanced AI retrieval system that supports Retrieval-Augmented Generation (RAG) and has production-grade features. It is built on a RESTful API and provides multimodal content ingestion, hybrid search, knowledge graph, and comprehensive document management capabilities.
Additionally, R2R includes a Deep Research API that pulls relevant data from knowledge bases and the internet to provide richer, more context-aware answers to complex queries.
Project Features
Main Features
Multimodal ingestion : support for parsing .txt
,.pdf
,.json
,.png
,.mp3
And other formats of files.Hybrid search : Combines semantic search and keyword search to improve retrieval results through reciprocal ranking fusion technology. Knowledge graph : Automatically extract entities and relationships and build a knowledge graph. Smart RAG : Integrated reasoning agent to enhance retrieval capabilities. User and Access Management : Provides a complete authentication and collection management system.
Usage scenarios
R2R can be widely used in scenarios that require efficient retrieval and knowledge management, such as:
Enterprise knowledge base management : quickly retrieve and integrate internal enterprise documents, materials, etc. Academic research : Assist researchers to quickly access relevant literature and knowledge. Intelligent Customer Service : Provide more accurate knowledge retrieval and answer generation for customer service systems. Market Analysis : Analyze market trends and social impact through in-depth research on APIs.
Project Usage
Cloud Service Options
When using R2R through SciPhi Cloud, you can enjoy a free tier without a credit card. For more information, see Quick Start [2] .
Self-hosted options
Quick installation and operation (light mode) :
pip install r2r
export OPENAI_API_KEY=sk-...
python -m r2r.serve
Run with Docker (full mode) :
git clone git@github.com:SciPhi-AI/R2R.git && cd R2R
export R2R_CONFIG_NAME=full OPENAI_API_KEY=sk-...
docker compose -f compose.full.yaml --profile postgres up -d
For detailed self-hosting instructions, please refer to the self-hosting documentation [3] .
Using the API
Install the SDK and set up :
Python:
pip install r2r
export R2R_API_KEY=pk_..sk_... # Get from SciPhi Cloud dashboard
JavaScript:
npm i r2r-js
export R2R_API_KEY=pk_..sk_... # Get from SciPhi Cloud dashboard
Client initialization :
Python:
from r2r import R2RClient
client = R2RClient() # If self-hosted, please specify base_url
JavaScript:
const { r2rClient } = require ( 'r2r-js' );
const client = new r2rClient(); // If self-hosted, please specify baseURL
Document Operations :
Create a sample document:
client.documents.create_sample(hi_res= True )
List documents:
client.documents.list()
Search with RAG :
Basic Search:
results = client.retrieval.search(query= "What is DeepSeek R1?" )
RAG with reference:
response = client.retrieval.rag(query= "What is DeepSeek R1?" )
RAG with inference:
response = client.retrieval.agent(
message={ "role" : "user" , "content" : "What does deepseek r1 imply? Think about market, sociological implications, and more." },
rag_generation_config={
"model" = "anthropic/claude-3-7-sonnet-20250219" ,
"extended_thinking" : True ,
"thinking_budget" : 4096 ,
"temperature" : 1 ,
"top_p" : None ,
"max_tokens_to_sample" : 16000 ,
},
mode = "research" # Deep research style output
)
Reference Documentation
R2R official documentation [4] SciPhi Cloud [5]