---
title: "Deploy LibreChat: Self-Hosted ChatGPT Alternative for Teams"
description: "Private AI chat for every model, with agents, search and file RAG."
category: "AI/ML"
url: https://railway.com/deploy/librechat-chatgpt-alternative
---

# Deploy LibreChat: Self-Hosted ChatGPT Alternative for Teams

Private AI chat for every model, with agents, search and file RAG.

**[Deploy LibreChat: Self-Hosted ChatGPT Alternative for Teams on Railway](https://railway.com/template/librechat-chatgpt-alternative)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/librechat-chatgpt-alternative/manifest.json

- **Creator:** blueorange
- **Category:** AI/ML

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### rag-api https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/librechat.svg

- **Image:** ghcr.io/danny-avila/librechat-rag-api-dev:v0.8.0
- **Health check:** /health

### meilisearch https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/meilisearch.svg

- **Image:** getmeili/meilisearch:v1.35.1
- **Health check:** /health

### LibreChat https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/librechat.svg

- **Image:** ghcr.io/danny-avila/librechat:v0.8.7
- **Health check:** /health
- **Public domain:** Yes

### MongoDB https://devicons.railway.app/i/mongodb.svg

- **Image:** mongo:8.0
- **Start command:** `docker-entrypoint.sh mongod --ipv6 --bind_ip ::,0.0.0.0 --setParameter diagnosticDataCollectionEnabled=false`

## Documentation

# Deploy and Host LibreChat on Railway

![LibreChat logo](https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/librechat.svg)

LibreChat is an open source, **ChatGPT-style chat app for every major AI model**, built for teams that want one private place to work with AI. It puts OpenAI, Anthropic, Google, AWS Bedrock, Azure, Mistral, Groq, DeepSeek, OpenRouter and local models behind a single interface, with agents, MCP tools, a code interpreter, artifacts, conversation search and file uploads with retrieval. LibreChat is MIT-licensed and has about 47,000 GitHub stars. This template deploys the complete stack on Railway: the LibreChat app, MongoDB for users and chats, Meilisearch for full-text search, and the RAG API with PostgreSQL and pgvector for document question answering. Embeddings run locally inside the RAG service, so uploaded files don't need an extra embeddings API key. You bring your own model keys and pay providers directly, so there are no per-seat fees. Railway hosting runs roughly $15–35/month for the five services.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **LibreChat** | The `librechat:v0.8.7` app on port `3080` with a public domain. Chat UI, API, agents and admin. Volume for uploaded images. |
| **MongoDB** | MongoDB 8.0 with a volume. Users, conversations, prompts, presets and agents. |
| **meilisearch** | Meilisearch 1.35 with a volume. Indexes messages so you can search old chats. |
| **rag-api** | LibreChat's RAG API. Splits and embeds uploaded files with a local `all-MiniLM-L6-v2` model and caches it on a volume. |
| **Postgres** | PostgreSQL 18 with pgvector. Stores the embeddings the RAG API searches. |

Encryption keys, JWT secrets and the Meilisearch master key are generated at deploy time and shared between services through Railway references.

---

## About Hosting LibreChat

Teams adopting AI quickly end up with a mix of ChatGPT, Claude and Gemini subscriptions, each with its own history, sharing rules and bill. LibreChat replaces that with one app on your own domain. Everyone signs in once, picks the model that fits the task, and their history stays in a database you control.

**First account is the admin.** There are no default credentials. The app opens on the sign-up page, and the first account you create becomes the administrator. Create it right away, then set `ALLOW_REGISTRATION=false` so no one else can sign up without an invite.

**Bring your own keys.** No model key ships with the template. Add provider keys as variables on the LibreChat service, or let each user enter their own key in the app. Either way, providers bill you directly at their normal API rates.

**Agents and tools.** LibreChat agents combine a model, instructions, files and tools such as web search, the code interpreter, OpenAPI actions and MCP servers. Share agents with your team so everyone uses the same well-tuned assistant.

**Documents with citations.** Upload PDFs, Word files or text, and the RAG API embeds them into pgvector. Ask questions about them in any conversation and get answers grounded in the file.

**Search everything.** Meilisearch indexes your messages, so finding an old answer is a keyword search instead of endless scrolling.

Typical cost: **~$15–35/month** on Railway for the five services at small-team scale, plus model usage. Per-seat AI chat plans charge for every user, whether they use it heavily or not.

---

## Deploy LibreChat in Under 10 Minutes

1. Click **Deploy on Railway**. All five services start and connect over the private network.
2. Open the LibreChat domain and register. This first account is the admin.
3. On the LibreChat service, set `ALLOW_REGISTRATION=false` and redeploy to close sign-ups.
4. Add a provider key, such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`, to the LibreChat variables and redeploy.
5. Start a chat, upload a document to test RAG, and search a past message.

Invite teammates by temporarily allowing registration or by setting up social login.

---

## Common Use Cases

- **Private ChatGPT for a company.** One URL, one login, every model, with chats kept in your own database.
- **Multi-model comparison.** Switch between GPT, Claude, Gemini and open models in the same conversation.
- **Document Q&A.** Ask questions about policies, contracts or research papers you upload.
- **Shared agents.** Publish a support, writing or coding agent once and let the team use it.
- **MCP tool hub.** Connect MCP servers so models can reach your internal tools and data.
- **Cost control.** Pay per token through your own keys instead of buying a seat for every person.
- **Local models.** Point LibreChat at Ollama or another OpenAI-compatible server for offline or sensitive work.

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `CREDS_KEY`, `CREDS_IV` | 🔐 Auto-generated | Encrypt stored provider keys. Keep them stable. |
| `JWT_SECRET`, `JWT_REFRESH_SECRET` | 🔐 Auto-generated | Sign access and refresh tokens. The RAG API references the same `JWT_SECRET`. |
| `MEILI_MASTER_KEY` | 🔐 Auto-generated | Shared between LibreChat and Meilisearch. |
| `MONGO_URI` | ✅ Auto-injected | MongoDB connection, database `LibreChat`. |
| `MEILI_HOST`, `RAG_API_URL` | ✅ Auto-set | Private URLs of Meilisearch and the RAG API. |
| `DOMAIN_CLIENT`, `DOMAIN_SERVER` | ✅ Auto-set | `https://` plus the public domain. |
| `ALLOW_REGISTRATION` | ✅ Set | `true` until you create the admin, then set it to `false`. |
| `ALLOW_EMAIL_LOGIN` | ✅ Set | `true`, email and password sign-in. |
| `ALLOW_SOCIAL_LOGIN`, `ALLOW_PASSWORD_RESET` | ✅ Set | `false` until you configure OAuth or email. |
| `MIN_PASSWORD_LENGTH` | ✅ Set | `12`. |
| `SEARCH`, `NO_INDEX` | ✅ Set | Message search on, search engines blocked. |
| `EMBEDDINGS_PROVIDER`, `EMBEDDINGS_MODEL` | ✅ Set | `huggingface` with `all-MiniLM-L6-v2`, running locally. |

**Adding models.** Set keys such as `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` or `GOOGLE_KEY` on the LibreChat service. Use `user_provided` as the value to let each user enter their own key.

**Sign-in options.** Email and password are on by default. Google, GitHub, Microsoft and OpenID Connect logins work once you add their OAuth credentials and set `ALLOW_SOCIAL_LOGIN=true`.

**Custom endpoints.** For OpenRouter, Ollama or other OpenAI-compatible APIs, add a `librechat.yaml` config as described in the LibreChat docs.

---

## LibreChat vs. Alternatives

| | LibreChat on Railway | ChatGPT Business | Open WebUI | LobeChat |
|---|---|---|---|---|
| **Monthly cost** | ~$15–35 plus tokens | Per user | Self-host costs | Self-host costs |
| **Self-hosted** | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |
| **Many model providers** | ✅ Yes | ❌ OpenAI only | ✅ Yes | ✅ Yes |
| **Agents with MCP tools** | ✅ Yes | ⚠️ GPTs and connectors | ⚠️ Tools and functions | ⚠️ Plugins |
| **Document RAG** | ✅ pgvector | ✅ Yes | ✅ Yes | ✅ Yes |
| **Full-text chat search** | ✅ Meilisearch | ✅ Yes | ⚠️ Basic | ⚠️ Basic |
| **License** | ✅ MIT | ❌ Proprietary | ⚠️ Own license | ⚠️ Own license |

---

## Dependencies for LibreChat Hosting

- Railway account. Pro is recommended for five services and the RAG embeddings model.
- API keys for the model providers you plan to use.
- Optional: OAuth app credentials for Google, GitHub or Microsoft sign-in, and SMTP for password resets.

### Deployment Dependencies

- [LibreChat on GitHub](https://github.com/danny-avila/LibreChat): source code and releases
- [LibreChat docs](https://www.librechat.ai/docs): configuration, agents and endpoints
- [LibreChat rag_api](https://github.com/danny-avila/rag_api): the document retrieval service
- [Railway Private Networking](https://docs.railway.com/guides/private-networking): how services connect

### Implementation Details

LibreChat is pinned to `v0.8.7` and the RAG API to `v0.8.0`; newer releases such as 0.8.8 are available, so back up MongoDB and Postgres before changing tags. The RAG API downloads its embeddings model once and keeps it on a volume, so restarts are fast. Meilisearch is limited to two indexing threads to stay within Railway's resources.

Only LibreChat has a public domain. MongoDB, Meilisearch, the RAG API and Postgres are reachable only over Railway's private network.

---

## Frequently Asked Questions

**What is LibreChat?**
An MIT-licensed, self-hosted chat app that gives your team one ChatGPT-style interface for many AI providers, with agents, file RAG and search.

**How much does it cost?**
About $15–35/month on Railway for all five services, plus what your providers charge for tokens. There are no per-seat fees.

**Who becomes the admin?**
The first account registered on a fresh deploy. Create it immediately, then set `ALLOW_REGISTRATION` to `false`.

**Do I need an embeddings API key for file uploads?**
No. The RAG API runs a small embeddings model locally and stores vectors in Postgres.

**Can each user bring their own API key?**
Yes. Set a provider's key variable to `user_provided` and users enter their own key in the app.

**Where are my chats stored?**
In MongoDB on a Railway volume, with search indexes in Meilisearch and document vectors in Postgres.

---

## 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 workspace for your team with search and document chat, without paying for a seat per person.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/librechat-chatgpt-alternative
