
Deploy R2R — Self-Hosted Agentic RAG Engine
Self-host R2R — agentic RAG, hybrid search & knowledge graphs
pgvector
Just deployed
/var/lib/postgresql
R2R-Dashboard
Just deployed
R2R-API
Just deployed
graph-clustering
Just deployed
Deploy and Host R2R on Railway
R2R is the most advanced open-source AI retrieval system — a production-ready RAG engine by SciPhi that goes far beyond simple vector search. It combines hybrid search (semantic plus keyword), automatic knowledge-graph construction, agentic multi-step research, and full document management, all behind a clean REST API with a management dashboard — the "Supabase for RAG," a complete retrieval backend for your AI apps. This template deploys R2R's full stack — API server, dashboard, pgvector database, and graph clustering — pre-wired, so you have a serious RAG engine running in minutes.
What This Template Deploys
| Service | Purpose |
|---|---|
| R2R API | The retrieval engine and REST API — search, RAG, agents, ingestion |
| R2R Dashboard | Next.js UI to manage documents, users, and collections |
| PostgreSQL + pgvector | Vector embeddings, documents, and knowledge-graph storage |
| Graph Clustering | Builds and clusters knowledge graphs from your documents |
All four connect over Railway's private network, pre-wired so ingestion, hybrid search, agentic retrieval, and graph construction work together out of the box.
About Hosting
R2R is a sophisticated, multi-service retrieval platform, and the value is in getting it wired correctly — all handled here.
Four services, pre-wired — the hard part done. R2R isn't a single container: it needs the API server, the dashboard, a pgvector database, and a dedicated graph-clustering service, all connected. This template wires them over the private network so ingestion, search, agentic RAG, and knowledge-graph building work immediately, instead of assembling four services and their connections by hand.
pgvector, not standard Postgres. R2R stores vector embeddings, documents, and graph data in PostgreSQL via the pgvector extension, which Railway's managed Postgres doesn't include — so this template uses the pgvector/pgvector:pg16 image with a dedicated volume. This is what powers R2R's hybrid semantic-plus-keyword search.
Agentic RAG and knowledge graphs — the real differentiator. Beyond retrieving chunks, R2R can run an agent that performs multi-step research over your documents with citations, and it automatically constructs knowledge graphs from your corpus, so retrieval understands entities and relationships, not just text similarity. It's a full retrieval system, not just a database.
Bring your own LLM key. Add OPENAI_API_KEY or ANTHROPIC_API_KEY on the R2R service, and it uses them for embeddings, generation, and the research agent. You pick the provider and pay it directly, with your documents and pipeline staying on your infrastructure.
Sign in with your dashboard credentials. After deploy, open the R2R Dashboard URL and sign in with the default credentials from NEXT_PUBLIC_R2R_DEFAULT_EMAIL and NEXT_PUBLIC_R2R_DEFAULT_PASSWORD — set strong values before deploying. From there, ingest documents, run searches, and manage users.
Build on the REST API. R2R exposes everything through a versioned REST API (default port 7272) — ingestion, search, RAG, and agent endpoints — with Python and JavaScript SDKs, so your apps call one retrieval backend instead of stitching together embedding, storage, and generation.
Typical cost: ~$15–25/month on Railway for the four services, plus your LLM provider usage. R2R is open source (Apache/MIT components) and free to self-host.
How It Compares
| R2R (self-hosted) | Plain vector DB | LangChain RAG | Managed RAG SaaS | |
|---|---|---|---|---|
| Hybrid search | Yes | Basic | Build it | Yes |
| Knowledge graphs | Automatic | No | Build it | Varies |
| Agentic research | Yes | No | Build it | Varies |
| REST API + dashboard | Yes | Partial | Build it | Yes |
| Data ownership | Full — your infra | Full | Full | Vendor |
| Self-hostable | Yes | Yes | Yes | No |
A plain vector database stores embeddings but leaves search, graphs, and orchestration to you. Building RAG from LangChain primitives means wiring ingestion, hybrid search, graphs, and agents yourself. Managed RAG platforms do this but hold your data and bill per usage. R2R's edge is a complete, production-grade retrieval system — hybrid search, automatic knowledge graphs, agentic research, and a REST API — self-hosted, with your data on infrastructure you own.
Deploy in Under 5 Minutes
- Click Deploy on Railway — the four services build and wire together (~5 minutes)
- Set
NEXT_PUBLIC_R2R_DEFAULT_EMAILandNEXT_PUBLIC_R2R_DEFAULT_PASSWORD - Add
OPENAI_API_KEYorANTHROPIC_API_KEYon the R2R service - Open the R2R Dashboard URL and sign in with your default credentials
- Ingest documents, then run hybrid search, RAG, or the research agent via the dashboard or API
Point your app at the R2R REST API to build retrieval into your own product.
Common Use Cases
- Production RAG backend — a complete retrieval engine behind your AI app via one REST API
- Agentic research — multi-step research over your documents with citations, not single lookups
- Document Q&A at scale — ingest and query large document sets with hybrid search
- Data-sovereign RAG — keep documents, embeddings, and the pipeline on your own infrastructure
Configuration
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY / ANTHROPIC_API_KEY | Required | Your LLM key for embeddings, generation, and the agent |
NEXT_PUBLIC_R2R_DEFAULT_EMAIL | Required | Default dashboard login email |
NEXT_PUBLIC_R2R_DEFAULT_PASSWORD | Required | Default dashboard password — set a strong value |
| Postgres connection | Auto-injected | pgvector database credentials via Railway references |
| Storage volume | Pre-set | Dedicated volume for the pgvector database |
pgvector is required, and four services are wired. R2R needs the
pgvector/pgvector:pg16image (not stock Postgres) for embeddings and graphs, and the API, dashboard, database, and clustering service are pre-connected over the private network.
Set dashboard credentials and add your LLM key. Configure the default email and password before deploying, and add
OPENAI_API_KEYorANTHROPIC_API_KEYon the R2R service for embeddings, generation, and the research agent.
Dependencies for R2R Hosting
- Railway account — ~$15–25/month for the four services, plus LLM provider usage
- PostgreSQL with pgvector (included and wired for embeddings and graphs)
- An LLM provider key (OpenAI or Anthropic) for embeddings, generation, and agents
- An application or the R2R SDK (Python/JavaScript) to call the retrieval API
Deployment Dependencies
Implementation Details
The template deploys R2R's full four-service stack over Railway's private network: the R2R API server (sciphiai/r2r), the Next.js R2R Dashboard (sciphiai/r2r-dashboard), a pgvector/pgvector:pg16 PostgreSQL database with a dedicated volume for embeddings, documents, and graph data, and a graph-clustering service (ragtoriches/cluster-prod) that builds knowledge graphs from ingested content. Standard Postgres lacks the pgvector extension R2R requires, which is why the pgvector image is used.
R2R provides hybrid search (semantic vector plus keyword), automatic knowledge-graph construction for entity- and relationship-aware retrieval, and an agentic RAG mode that performs multi-step research over documents with citations, all exposed through a versioned REST API on port 7272 with Python and JavaScript SDKs. LLM provider keys (OPENAI_API_KEY or ANTHROPIC_API_KEY) are added on the R2R service and drive embeddings, generation, and the research agent.
The dashboard is reachable at its Railway URL, with initial access via NEXT_PUBLIC_R2R_DEFAULT_EMAIL and NEXT_PUBLIC_R2R_DEFAULT_PASSWORD, from which documents, users, and collections are managed. Documents, embeddings, and graph data persist in the pgvector database, which is the component to back up.
Frequently Asked Questions
What makes R2R more than a vector database? R2R is a full retrieval system: on top of vector storage it adds hybrid search, automatic knowledge graphs, an agentic research mode with citations, document management, and a REST API. A plain vector DB leaves all of that for you to build.
Why does R2R need pgvector? It stores embeddings, documents, and graph data in PostgreSQL via the pgvector extension, which Railway's managed Postgres doesn't include. This template uses the pgvector/pgvector:pg16 image so retrieval works.
How do I sign in to the dashboard? Open the R2R Dashboard URL and use the credentials from NEXT_PUBLIC_R2R_DEFAULT_EMAIL and NEXT_PUBLIC_R2R_DEFAULT_PASSWORD. Set strong values before deploying.
Does my data persist? Yes — documents, embeddings, and knowledge graphs live in the pgvector database and survive redeploys. Back it up to preserve your ingested corpus.
Why Deploy R2R on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying R2R on Railway you get the most advanced open-source retrieval system with the hard parts solved — four services pre-wired, pgvector for hybrid search and graphs, BYOK LLM providers, and a REST API and dashboard. A production-grade RAG engine, self-hosted on infrastructure you own.
Template Content
pgvector
pgvector/pgvector:pg18R2R-Dashboard
sciphiai/r2r-dashboard:1.0.3R2R-API
sciphiai/r2r:latestgraph-clustering
ragtoriches/cluster-prod