---
title: "Deploy R2R | The most advanced AI retrieval system by SciPhi"
description: "Self-Host R2R. Agentic RAG, hybrid search, document management with API"
category: "AI/ML"
url: https://railway.com/deploy/r2r
---

# Deploy R2R | The most advanced AI retrieval system by SciPhi

Self-Host R2R. Agentic RAG, hybrid search, document management with API

**[Deploy R2R | The most advanced AI retrieval system by SciPhi on Railway](https://railway.com/template/r2r)**

- **Creator:** Heimdall
- **Category:** AI/ML
- **Total deploys:** 3

## Template content

### graph-clustering

- **Image:** ragtoriches/cluster-prod

### pgvector https://devicons.railway.app/postgres

- **Image:** pgvector/pgvector:pg18
- **Start command:** `/bin/sh -c "unset PGPORT; docker-entrypoint.sh postgres --port=5432"`
- **Public domain:** Yes

### R2R-API https://res.cloudinary.com/asset-cloudinary/image/upload/v1777645933/c3b41471-625e-458d-8f1a-13e8c16a8699.png

- **Image:** sciphiai/r2r:latest
- **Public domain:** Yes

### R2R-Dashboard https://res.cloudinary.com/asset-cloudinary/image/upload/v1777645933/c3b41471-625e-458d-8f1a-13e8c16a8699.png

- **Image:** sciphiai/r2r-dashboard:1.0.3
- **Public domain:** Yes

## Documentation

![R2R logo](https://opengraph.githubassets.com/cb3eb4a34c113b7383b93bbf7eae59b8d54edacb4e79036601f42d476ea25371/SciPhi-AI/R2R)

# Deploy and Host R2R on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/r2r?referralCode=QXdhdr)

Deploy R2R on Railway to run your own production-ready RAG engine with a RESTful API, hybrid search, knowledge graphs, and a management dashboard. Self-host R2R and keep full control of your data and retrieval pipeline.

This template pre-configures the R2R API server (`sciphiai/r2r:latest`), R2R Dashboard (`sciphiai/r2r-dashboard:1.0.3`), PostgreSQL with pgvector (`pgvector/pgvector:pg16`), and a graph-clustering service (`ragtoriches/cluster-prod`). Internal services communicate over Railway's private network.

![R2R Railway architecture](https://res.cloudinary.com/asset-cloudinary/image/upload/v1777646273/1a1e194a-75da-4c20-97e8-cd4489b2cdc1.png)

## Getting Started with R2R on Railway

After deploying, open the R2R Dashboard URL. Sign in with the default credentials from your environment variables (`NEXT_PUBLIC_R2R_DEFAULT_EMAIL` / `NEXT_PUBLIC_R2R_DEFAULT_PASSWORD`). Add your LLM provider API key (`OPENAI_API_KEY` or `ANTHROPIC_API_KEY`) on the R2R service in Railway. Upload your first document via the dashboard or the REST API:

```
curl -X POST https://your-r2r-domain.up.railway.app/v3/documents \
  -H "Content-Type: multipart/form-data" \
  -F "file=@your-document.pdf"
```

Query your ingested documents with a RAG request:

```
curl -X POST https://your-r2r-domain.up.railway.app/v3/retrieval/rag \
  -H "Content-Type: application/json" \
  -d '{"query": "What are the key findings?", "search_settings": {"use_hybrid_search": true}}'
```

![R2R dashboard screenshot](https://res.cloudinary.com/asset-cloudinary/image/upload/v1777645949/8cfa620b-7ee9-4760-ae5e-e5b441639c48.png)

## About Hosting R2R

R2R (Retrieval to Response) is an open-source (MIT) agentic RAG engine by SciPhi with 18k+ GitHub stars, backed by Y Combinator. It provides a complete API-first platform for production-grade retrieval.

Key features:

- **Multimodal ingestion** -- PDFs, Markdown, images, audio, and JSON
- **Hybrid search** -- semantic vector search plus keyword search with reciprocal rank fusion
- **Knowledge graphs** -- automatic entity and relationship extraction via Graph RAG
- **Deep Research API** -- multi-step reasoning across your knowledgebase and the web
- **User and document management** -- built-in auth, collections, per-user scoping
- **RESTful API** -- Python and TypeScript SDKs included

## Why Deploy R2R on Railway

- One-click deploy with Postgres (pgvector), dashboard, and graph clustering pre-wired
- Private network keeps database and clustering services unexposed
- All configuration via environment variables -- no YAML or config files to manage
- Bring your own LLM provider key (OpenAI, Anthropic, or others)
- MIT license with no usage restrictions

## Common Use Cases for Self-Hosted R2R

- **Internal knowledge base** -- ingest company docs and query them with natural language
- **AI-powered product search** -- add semantic search to your SaaS using R2R's retrieval endpoints
- **Document Q&A chatbot** -- power a customer-facing chatbot grounded in your documentation
- **Research automation** -- run multi-step queries across large document collections

## Dependencies for R2R on Railway

This template deploys four services:

- **R2R** -- `sciphiai/r2r:latest` -- main RAG API server (Python, FastAPI)
- **R2R-Dashboard** -- `sciphiai/r2r-dashboard:1.0.3` -- Next.js management UI
- **Postgres** -- `pgvector/pgvector:pg16` -- PostgreSQL with pgvector for vector embeddings
- **graph-clustering** -- `ragtoriches/cluster-prod` -- knowledge graph clustering service

### Environment Variables Reference for R2R

| Variable | Description | Example |
|----------|-------------|---------|
| `R2R_SECRET_KEY` | API encryption and signing key | `${{secret(64)}}` |
| `R2R_POSTGRES_HOST` | Internal Postgres hostname | `${{Postgres.RAILWAY_PRIVATE_DOMAIN}}` |
| `NEXT_PUBLIC_R2R_DEPLOYMENT_URL` | R2R API URL for dashboard | `https://${{R2R.RAILWAY_PUBLIC_DOMAIN}}` |
| `NEXT_PUBLIC_R2R_DEFAULT_EMAIL` | Dashboard login email | `admin@example.com` |
| `OPENAI_API_KEY` | LLM provider key (optional) | Your API key |

### Deployment Dependencies for R2R

- **Runtime:** Python 3.10+, Node.js (Next.js dashboard)
- **GitHub:** [SciPhi-AI/R2R](https://github.com/SciPhi-AI/R2R)
- **Docker Hub:** [sciphiai/r2r](https://hub.docker.com/r/sciphiai/r2r), [sciphiai/r2r-dashboard](https://hub.docker.com/r/sciphiai/r2r-dashboard)
- **Docs:** [r2r-docs.sciphi.ai](https://r2r-docs.sciphi.ai)

## Hardware Requirements for Self-Hosting R2R

| Resource | Minimum | Recommended |
|----------|---------|-------------|
| CPU | 2 vCPU | 4 vCPU |
| RAM | 4 GB | 8 GB |
| Storage | 2 GB | 10 GB+ |
| GPU | Not required | Not required |

R2R delegates inference to external LLM providers, so no GPU is needed. On Railway's 8 GB plan, all four services run comfortably.

## Self-Hosting R2R with Docker

Clone the repository and run all services with Docker Compose:

```
git clone https://github.com/SciPhi-AI/R2R.git
cd R2R
docker compose -f compose.full.yaml --profile postgres up -d
```

Or run the core services individually with Docker:

```
docker run -d --name r2r-postgres \
  -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=changeme \
  -e POSTGRES_DB=postgres pgvector/pgvector:pg16

docker run -d --name r2r -p 7272:7272 \
  -e R2R_HOST=0.0.0.0 -e R2R_PORT=7272 \
  -e R2R_POSTGRES_HOST=r2r-postgres \
  -e R2R_POSTGRES_USER=postgres \
  -e R2R_POSTGRES_PASSWORD=changeme \
  sciphiai/r2r:latest
```

Access the API at `http://localhost:7272`.

## Is R2R Free to Self-Host on Railway?

R2R is fully open-source under the MIT license. SciPhi offers a managed cloud with a free tier (300 RAG requests/month) and enterprise plans. Self-hosting on Railway means you pay only for infrastructure plus your LLM provider API costs.

## FAQ: Self-Hosting R2R on Railway

**What is R2R and why should I self-host it?**
R2R is an open-source RAG engine by SciPhi providing hybrid search, knowledge graphs, and document management via a REST API. Self-hosting gives you full data control and lets you use any LLM provider.

**What does this Railway template deploy for R2R?**
Four services: the R2R API server, a Next.js dashboard, PostgreSQL with pgvector for vector embeddings, and a graph-clustering service. Database and clustering run on Railway's private network.

**Why does R2R need PostgreSQL with pgvector on Railway?**
R2R stores vector embeddings in PostgreSQL using pgvector. Railway's managed Postgres lacks this extension, so the template uses `pgvector/pgvector:pg16` with a dedicated volume.

**How do I add my OpenAI or Anthropic API key to R2R on Railway?**
Open the R2R service in Railway, go to Variables, and add `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`. Redeploy the service. R2R supports multiple providers simultaneously.

**Can I use R2R without an LLM API key on Railway?**
The API server starts and accepts document uploads without an LLM key. RAG queries require at least one provider key, but hybrid search and document management work independently.

**How do I scale R2R for larger document collections on Railway?**
Increase `R2R_POSTGRES_MAX_CONNECTIONS` if you see pool exhaustion. For heavier workloads, scale the R2R service vertically in Railway (more CPU/RAM).


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/r2r
