Deploy Deploy RAGFlow Retrieval API

RAGFlow HTTP API for retrieval and chat

Deploy Deploy RAGFlow Retrieval API

Just deployed

/var/lib/mysql

Just deployed

/usr/share/elasticsearch/data

Just deployed

/ragflow/logs

Just deployed

/data

Deploy and Host self hosted RAGFlow API (Open-Source RAG Engine) on Railway

This template runs RAGFlow v0.27.2 as an HTTP retrieval and chat backend. Create a key in the UI, call your-domain/api/v1 with a Bearer header, and cite sources from your own app without owning a parsing pipeline.

About Hosting RAGFlow API open-source software on Railway (self hosted RAGFlow template)

Your documents stay in infrastructure you control: MySQL, Elasticsearch, Redis and a MinIO-compatible store, all inside your Railway project, with secrets generated per deploy.

Railway wires the five services, their volumes, the health check and private networking, which is the part that usually eats a weekend. Model provider keys go in the UI after deploy, not in env vars.

Why Deploy RAGFlow API, the Dify alternative on Railway (Railway Free Trial)

Dify bundles RAG into a broader LLM app builder, so you inherit its whole stack. RAGFlow ships a retrieval API that hands ranked chunks with source info back to your own LLM.

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 RAGFlow API on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Railway vs Other Hosting Providers and VPS for RAGFlow API self hosting

Five services must be wired before the first retrieval call works; the difference is who does that.

ProviderWhat You Get with RailwayWhat You Get with the Other Provider
DigitalOceanFive-service stack, generated secrets, HTTPS domain proxying /api.Droplet where you install Docker, raise vm.max_map_count, and manage certs.
AWSUsage-based memory and CPU billing, per-service logs and metrics.ECS or EC2 plus RDS, OpenSearch, and S3 you assemble and patch.
HetznerScale memory per service, no whole 16 GB box required.Cheap 4 CPU, 16 GB instances with everything installed by hand.

The API is the same; the plumbing is not.

Common Use Cases for hosted RAGFlow API

  • Retrieval for your own LLM: POST /api/v1/retrieval with a question and dataset_ids returns ranked chunks and sources, so you keep your existing prompt and model.
  • OpenAI-compatible chat in an app: point the OpenAI SDK at https://your-domain/api/v1/openai/CHAT_ID and reuse a chat assistant configured in the UI.
  • Scripted ingestion: create datasets, upload and parse files through /api/v1/datasets from a cron job or CI step, then poll document status.
  • Support bot backend: call retrieval from your helpdesk webhook and pass the top chunks into your own answer prompt with citations.
  • Retrieval evaluation: run a fixed question set against /api/v1/retrieval, vary top_k or similarity_threshold, and compare returned chunks before shipping a chunking change.

Dependencies for RAGFlow API Docker hosted on Railway

RAGFlow isn't one container. This template runs five Railway services, and /api/v1/system/healthz returns 200 only when MySQL, Elasticsearch, Redis, and the S3 store all answer. Every credential is generated per deploy.

Deployment Dependencies for Managed RAGFlow API Service (RAG Engine)

  • ragflow: port 80 (nginx, UI, API 9380, admin 9381, executor), volume /ragflow/logs.
  • Elasticsearch 8.11.3: doc engine, 1 GB heap, volume /usr/share/elasticsearch/data.
  • MinIO (pgsty/silo): S3 store for uploads, volume /data.
  • MySQL 8.4.11: database rag_flow, volume /var/lib/mysql.
  • Redis 8.2.10: queue and locks, volume /data.
  • Secrets: RAGFLOW_SECRET_KEY, ADMIN_DEFAULT_PASSWORD, ELASTIC_PASSWORD, MINIO_ROOT_PASSWORD, MYSQL_ROOT_PASSWORD, REDIS_PASSWORD.

Implementation Details for RAGFlow API (Using RAGFlow official docker image)

Fixed variables: DOC_ENGINE=elasticsearch, DEVICE=cpu, DB_TYPE=mysql, REGISTER_ENABLED=1, HF_ENDPOINT=https://huggingface.co, DOC_BULK_SIZE=4, EMBEDDING_BATCH_SIZE=16, USE_DOCLING=false, TZ=UTC.

How does RAGFlow API compare against other RAG engines

RAGFlow API vs Dify (Dify Alternative)

  • Parsing depth: RAGFlow runs DeepDoc layout-aware parsing on PDFs, scans, and tables; Dify leans on simpler extractors.
  • App surface: Dify wins if you want prompt orchestration, workflows, and many model providers in one UI.
  • API shape: Both expose HTTP; RAGFlow's retrieval endpoint returns ranked chunks with document info you can drop into your own prompt.

RAGFlow API vs LlamaIndex (LlamaIndex Alternative)

  • Code vs config: LlamaIndex is a library you write; RAGFlow is a service you call, with parsing and chunking handled for you.
  • Chunk control: LlamaIndex wins on fine-grained pipeline control and custom retrievers.
  • Ops cost: With LlamaIndex you own the vector store and parsing infra; here it ships in one template.

RAGFlow API vs Vectara (Vectara Alternative)

  • Hosting: Vectara is a managed commercial service; this runs on your Railway project with your own keys.
  • Parsing: RAGFlow gives you visual chunk inspection and template chunking; Vectara hides more of that.
  • Where Vectara wins: no Elasticsearch, MySQL, or Redis to babysit, and less capacity planning.

RAGFlow API vs building on a vector database (Vector Database Alternative)

  • Scope: A vector DB stores and searches vectors; RAGFlow adds parsing, chunking, hybrid search, and rerank.
  • Retrieval quality: Hybrid vector plus full-text plus rerank usually beats raw vector similarity out of the box.
  • Where the DB wins: cost and footprint if your documents are already clean text and chunking is solved.
  • Migration: You can keep both, call /api/v1/retrieval for grounded chunks, and leave writes to your existing store.

How to use RAGFlow API (the OSS RAG engine)?

  1. Open https://your-domain, register, log in.
  2. Add LLM, embedding, rerank keys in Model providers.
  3. Create a dataset, upload files, hit parse. Parsing is async.
  4. Avatar menu, API, create a key. Keep it server side.
  5. Copy the dataset id.
  6. Test retrieval:
curl https://your-domain/api/v1/retrieval -H "Authorization: Bearer your-key" -H "Content-Type: application/json" -d '{"question":"refund window","dataset_ids":["DS_ID"]}'
  1. Create a chat assistant, then:
from openai import OpenAI
c = OpenAI(api_key="your-key", base_url="https://your-domain/api/v1/openai/CHAT_ID")
c.chat.completions.create(model="ragflow", messages=[{"role":"user","content":"hi"}])
  1. Script uploads with pip install ragflow-sdk, base_url https://your-domain.

How to self host RAGFlow API on other VPS Services (RAGFlow self hosting guide)

Same four steps on any VPS: clone, install, configure, start. They mirror what the Railway template already did for you.

Clone the Repository

git clone https://github.com/infiniflow/ragflow
cd ragflow/docker

Install Dependencies

Docker 24+ with the compose plugin, plus the Elasticsearch host limit:

sudo sysctl -w vm.max_map_count=262144

Plan for 4 CPU cores, 16 GB RAM and 50 GB of disk.

Configure Environment Variables

Copy the env template, then set DB_TYPE=mysql, DOC_ENGINE=elasticsearch, and your own MySQL, Redis, MinIO and Elasticsearch passwords plus RAGFLOW_SECRET_KEY.

Start the RAGFlow API Application

docker compose -f docker-compose.yml up -d

The web UI and API answer on port 80 of the host, with nginx forwarding /api to the API server on 9380. Poll /api/v1/system/healthz until it returns 200, register the first account, then set REGISTER_ENABLED=0.

Railway handles the host tuning, TLS, the health-based rollouts and the wiring between all five services for you.

Official Pricing of RAGFlow API (RAGFlow pricing)

RAGFlow itself is Apache-2.0 and free to self host.

RAGFlow API cloud vs self hosted comparison (Pricing, features, costs, and more)

The API surface is the same whether you self host or buy a managed plan: the same retrieval endpoint, the same OpenAI-compatible chat path, the same SDK calls.

Monthly cost of self hosting RAGFlow API on Railway

Expect roughly $40-80/mo on Railway for this five service stack, because Elasticsearch, MySQL, and the RAGFlow container with its DeepDoc models need several GB of RAM. Large knowledge bases push it higher.

System Requirements for Hosting RAGFlow API on a VPS

Upstream asks for 4 CPU cores, 16 GB RAM, 50 GB disk, Docker 24+, and vm.max_map_count set to 262144 for Elasticsearch. Below that, parsing crawls or Elasticsearch refuses to start.

Frequently Asked Questions (FAQs)

Where do I get the API key?

Open the RAGFlow domain, click your avatar, then API, and create a key. Treat it like a password: keep it server side and send it as Authorization: Bearer your-key on every call.

Should I use the retrieval endpoint or the chat endpoint?

Use POST /api/v1/retrieval when you want ranked chunks to paste into your own LLM prompt.

Is the chat API OpenAI compatible?

Yes. Point any OpenAI SDK at base URL https://your-domain/api/v1/openai/CHAT_ID and pass standard messages. The older chats_openai path is deprecated in v0.27.2, so update old clients.

How do I upload and parse files by API?

Create a dataset, upload documents, then trigger parsing, all under /api/v1/datasets. You can also script it with pip install ragflow-sdk and RAGFlow(api_key=..., base_url=...).

Is parsing synchronous?

No. Parsing runs asynchronously in the task executor, so the upload call returns before chunks exist. Poll document status until parsing finishes, then run retrieval.

Can I call it from another Railway service?

Yes. Use the ragflow service over the private network on port 80, or the public domain for anything outside Railway.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
7
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
89