Deploy LibreChat

Self-hosted LibreChat: GPT, Claude, Gemini in one app. ChatGPT alternative.

Deploy LibreChat

Just deployed

/var/lib/postgresql/data

Just deployed

MongoDB

mongo:8.0

Just deployed

/data/db

/data

Deploy and Host LibreChat on Railway

LibreChat chat interface with model picker and conversation history

LibreChat is the open-source AI chat platform with 46,000+ GitHub stars: one ChatGPT-style interface for OpenAI, Anthropic, Google, OpenRouter and many more models, with agents, file search and conversation history. ChatGPT Business and Claude Team cost $20–25 per seat per month — self-host LibreChat on Railway for ~$12–20/month plus the API usage you actually pay for, and keep every conversation in your own database.


What This Template Deploys

ServicePurpose
LibreChatWeb app and API (port 3080, public HTTPS domain, /health check). Built from the template's GitHub source; creates an admin account on first start.
MongoDBMongoDB 8. Stores users, conversations, messages, presets and agents.
MeilisearchMeilisearch v1.35 for full-text search across your conversations.
rag-apiLibreChat RAG API (lite) — embeds uploaded files so you can chat with PDFs and documents.
VectorDBPostgreSQL 17 with pgvector. Stores file embeddings for the RAG API.
Persistent Volume/data on LibreChat — uploads, generated images and logs.
Persistent Volume/data/db on MongoDB and /var/lib/postgresql/data on VectorDB — conversations and embeddings survive redeploys.

Five services on Railway's private network. Only LibreChat is public; databases, search and the RAG API are internal.


About Hosting LibreChat

A complete LibreChat install needs the app, MongoDB, Meilisearch for search, a RAG API and a vector database for file chat, plus secrets in exact formats: CREDS_KEY must be 64 hex characters and CREDS_IV 32. Getting all of that right by hand takes Docker Compose, a reverse proxy and careful key generation.

On Railway, all five services start together, LibreChat gets an HTTPS domain, DOMAIN_CLIENT and DOMAIN_SERVER point at it automatically, and every secret is generated in the correct format. Registration is closed by default, and an admin account is created from ADMIN_EMAIL on first start.

File search needs an OpenRouter key. The RAG API creates embeddings through OpenRouter using OPENROUTER_KEY from the LibreChat service. Leave it empty and chat still works with per-user keys, but uploading files for search won't.

Typical cost: ~$12–20/month on Railway for the stack, plus the AI API usage you choose. ChatGPT Business is $20 per seat per month (annual; $25 monthly) and Claude Team $20–25 per standard seat — a 10-person team pays $200–250/month before anyone sends a message.


Deploy LibreChat in Under 10 Minutes

  1. Set ADMIN_EMAIL when deploying — it's the only required input.
  2. Click Deploy on Railway — LibreChat builds and the databases start (~5–8 minutes).
  3. Copy ADMIN_PASSWORD from the LibreChat service's variables and sign in at the public URL.
  4. Add an OPENROUTER_KEY (or your own OpenAI, Anthropic or Google keys) to enable models for everyone, or let each user paste their own key in the UI.
  5. Set ALLOW_REGISTRATION to true while your team signs up, then back to false.

No Docker Compose. No hand-made encryption keys. No reverse proxy.


Common Use Cases

  • Self-hosted ChatGPT alternative — "open source chatgpt alternative" with no per-seat pricing
  • One interface for every model — switch between GPT, Claude, Gemini and OpenRouter models mid-conversation
  • Team AI workspace — shared agents and presets on one private instance
  • Chat with your documents — upload PDFs and files and ask questions with RAG
  • Private AI for sensitive data — conversations stay in your own MongoDB, not a vendor's app
  • Pairs with n8n — connect LibreChat agents to your automations through MCP and APIs

Configuration

VariableRequiredDescription
ADMIN_EMAIL✅ RequiredEmail of the admin account created on first start.
ADMIN_PASSWORD🔐 Auto-generatedAdmin password — copy it from the variables to sign in.
OPENROUTER_KEYOptionalOne key for chat models and file search for everyone.
OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_KEYOptionaluser_provided lets each user enter their own key; replace with a real key to share one.
CREDS_KEY, CREDS_IV🔐 Auto-generatedEncrypt stored API keys. Never change them after users save keys.
JWT_SECRET, JWT_REFRESH_SECRET🔐 Auto-generatedSign sessions; JWT_SECRET is shared with the RAG API.
DOMAIN_CLIENT, DOMAIN_SERVER✅ Auto-injectedPublic URL. Update both when you add a custom domain.
ALLOW_REGISTRATIONOptionalfalse by default. Turn on briefly so your team can sign up.
MONGO_URI, MEILI_*, RAG_API_URL✅ Auto-injectedPrivate connections to MongoDB, Meilisearch and the RAG API.

Keep CREDS_KEY and CREDS_IV safe. LibreChat doesn't re-encrypt stored keys when they change, so replacing them makes every saved user API key unreadable.


LibreChat vs. Alternatives

LibreChat (Railway)ChatGPT BusinessClaude TeamOpen WebUI (self-hosted)
Monthly cost~$12–20 + API usage$20–25 per seat$20–25 per seatFree, you host it
Self-hosted✅ Yes❌ No❌ No✅ Yes
Per-seat pricing✅ None❌ Per seat❌ Per seat✅ None
Models from many providers✅ OpenAI, Anthropic, Google, OpenRouter…❌ OpenAI only❌ Anthropic only✅ Ollama and OpenAI-compatible
Chat with files (RAG)✅ Built in✅ Built in✅ Built in✅ Built in
Agents and tools✅ Agents and MCP✅ Yes✅ Yes✅ Tools and functions
Data stays on your infra✅ Yes❌ No❌ No✅ Yes
License✅ MIT❌ Proprietary❌ Proprietary⚠️ Open WebUI License (branding terms)

Dependencies for LibreChat Hosting

  • Railway account — Hobby ($5/month) runs it; plan for ~1.2–1.5 GB RAM across five services.
  • API keys for the models you want (OpenRouter, OpenAI, Anthropic or Google), either shared or per user.
  • An OpenRouter key if you want file search (RAG).

Deployment Dependencies

Implementation Details

LibreChat builds from the template's GitHub source and talks to mongo:8.0, getmeili/meilisearch:v1.35.1, the librechat-rag-api-dev-lite RAG API and pgvector/pgvector:pg17 over the private network. MongoDB binds with IPv6 for Railway's internal network, and uploads live on the /data volume.

The values to protect are CREDS_KEY and CREDS_IV, which encrypt user API keys, and JWT_SECRET, which the RAG API also uses. DOMAIN_CLIENT and DOMAIN_SERVER must match the public URL — update both together for a custom domain.


Frequently Asked Questions

What is LibreChat and why self-host it? LibreChat is an open-source ChatGPT-style interface that works with many AI providers in one place. Self-hosting removes per-seat fees, lets you pick any model, and keeps conversations in your own database.

How much does self-hosting LibreChat cost compared to ChatGPT Business? About $12–20/month in Railway usage plus pay-as-you-go API costs. ChatGPT Business is $20 per seat per month billed annually ($25 monthly), so 10 users cost $200–250/month on seats alone.

Why isn't file upload or file search working in LibreChat? The RAG API needs OPENROUTER_KEY on the LibreChat service to create embeddings. Add the key and redeploy rag-api; until then, chat works but file search doesn't.

Do I lose conversations when I redeploy? No. Conversations, users and agents live in MongoDB on a persistent volume, file embeddings in pgvector, and uploads on LibreChat's /data volume. The Meilisearch index has no volume and is rebuilt from MongoDB after a redeploy.

Can I use Claude, Gemini or local models with LibreChat? Yes. LibreChat supports OpenAI, Anthropic, Google, AWS Bedrock, OpenRouter, Groq, Mistral, DeepSeek and more, plus any OpenAI-compatible endpoint through custom endpoints.

How do users get accounts if registration is closed? The admin account is created from ADMIN_EMAIL on first start. To add your team, set ALLOW_REGISTRATION to true, let them sign up, then set it back to false.


Why Deploy and Host LibreChat 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 LibreChat on Railway, you get a private, multi-model AI chat for your team — agents, file search and conversation search — for a flat hosting cost plus only the API usage you choose.


Template Content

MongoDB

mongo:8.0

More templates in this category

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

okisdev
117
View Template
NEW
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

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

Jan Kubica
7