Overview
R2R (Reason to Retrieve) is an open-source retrieval system for building Retrieval-Augmented Generation (RAG) applications. It runs as a server with a RESTful API and handles the parts of a RAG pipeline you would otherwise wire together yourself: ingesting documents, searching over them, and generating answers with citations.
It is aimed at developers who need more than a single-file demo. Alongside basic search and RAG, it includes multimodal ingestion, hybrid (semantic plus keyword) search, automatic knowledge-graph extraction, user and access management, and an agentic Deep Research API that runs multi-step reasoning over your knowledge base and the web.
As a RAG framework, R2R sits between raw vector stores and your application. You talk to it through Python or JavaScript SDK clients (or the API directly), so the retrieval and document-management logic lives in one service rather than scattered across your app code.
What it does
- Multimodal ingestion: parse .txt, .pdf, .json, .png, .mp3, and more file types
- Hybrid search combining semantic and keyword retrieval with reciprocal rank fusion
- Automatic knowledge graphs with entity and relationship extraction
- Agentic RAG, including a Deep Research API for multi-step reasoning over your data and the internet
- Built-in user and access management with authentication and collections
- RESTful API with Python (r2r) and JavaScript (r2r-js) SDK clients
Getting started
Install R2R, start the server in light mode, then connect a client to ingest documents and run searches.
Install and run in light mode
Install the Python package, set your OpenAI API key, and start the server. Light mode runs without Docker.
pip install r2r
export OPENAI_API_KEY=sk-...
python -m r2r.serveInstall the SDK
Use the Python SDK, or install r2r-js for JavaScript projects.
pip install r2r # Python
# or
npm i r2r-js # JavaScriptInitialize the client
Point the client at your running R2R server.
from r2r import R2RClient
client = R2RClient(base_url="http://localhost:7272")Ingest a document and search
Add a document, then run a search or a RAG query with citations.
# Ingest your own document
client.documents.create(file_path="/path/to/file")
# Basic search
results = client.retrieval.search(query="What is DeepSeek R1?")
# RAG with citations
response = client.retrieval.rag(query="What is DeepSeek R1?")Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Add a searchable knowledge base with cited answers to an internal app without building the RAG pipeline from scratch
- Ingest mixed file types (PDFs, images, audio, JSON) and query them through one API
- Build a knowledge graph from a document collection to surface entities and relationships
- Run multi-step Deep Research queries that reason over both your data and the web
How R2R compares
R2R alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Dify | ★ 148k | An open-source platform with a visual workflow builder for creating LLM and RAG applications without writing much code. |
| RAGFlow | ★ 84.6k | A RAG engine built around deep document understanding that turns complex files into a grounded, citation-backed question-answering layer. |
| Context7 | ★ 58.8k | Context7 pulls current, version-specific documentation and code examples for any library and feeds them into your LLM, available as a CLI skill or an MCP server. |
| Quivr | ★ 39.2k | Quivr is an open-source RAG framework that ingests your documents and answers questions about them, working with any LLM and any file type. |
| LightRAG | ★ 37.5k | A graph-based RAG system that builds an entity-and-relationship knowledge graph for fast retrieval and easy incremental updates. |
| GraphRAG | ★ 34.3k | Microsoft's graph-based RAG system that extracts a knowledge graph from documents to answer broad, multi-document questions. |
| PageIndex | ★ 33.9k | PageIndex turns long PDFs into a table-of-contents tree and uses LLM reasoning to retrieve relevant sections, with no vector database and no chunking. |
| R2R | ★ 7.9k | A RAG server with ingestion, hybrid search, and knowledge graphs behind a REST API |