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

/var/lib/postgresql/data

/app/hf-cache

Just deployed

/meili_data

Just deployed

/app/client/public/images

MongoDB

mongo:8.0

Just deployed

/data/db

Deploy and Host LibreChat on Railway

LibreChat logo

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

ServicePurpose
LibreChatThe librechat:v0.8.7 app on port 3080 with a public domain. Chat UI, API, agents and admin. Volume for uploaded images.
MongoDBMongoDB 8.0 with a volume. Users, conversations, prompts, presets and agents.
meilisearchMeilisearch 1.35 with a volume. Indexes messages so you can search old chats.
rag-apiLibreChat's RAG API. Splits and embeds uploaded files with a local all-MiniLM-L6-v2 model and caches it on a volume.
PostgresPostgreSQL 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

VariableRequiredDescription
CREDS_KEY, CREDS_IV🔐 Auto-generatedEncrypt stored provider keys. Keep them stable.
JWT_SECRET, JWT_REFRESH_SECRET🔐 Auto-generatedSign access and refresh tokens. The RAG API references the same JWT_SECRET.
MEILI_MASTER_KEY🔐 Auto-generatedShared between LibreChat and Meilisearch.
MONGO_URI✅ Auto-injectedMongoDB connection, database LibreChat.
MEILI_HOST, RAG_API_URL✅ Auto-setPrivate URLs of Meilisearch and the RAG API.
DOMAIN_CLIENT, DOMAIN_SERVER✅ Auto-sethttps:// plus the public domain.
ALLOW_REGISTRATION✅ Settrue until you create the admin, then set it to false.
ALLOW_EMAIL_LOGIN✅ Settrue, email and password sign-in.
ALLOW_SOCIAL_LOGIN, ALLOW_PASSWORD_RESET✅ Setfalse until you configure OAuth or email.
MIN_PASSWORD_LENGTH✅ Set12.
SEARCH, NO_INDEX✅ SetMessage search on, search engines blocked.
EMBEDDINGS_PROVIDER, EMBEDDINGS_MODEL✅ Sethuggingface 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 RailwayChatGPT BusinessOpen WebUILobeChat
Monthly cost~$15–35 plus tokensPer userSelf-host costsSelf-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

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.


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
Weaviate
Vector database with hybrid search and an API key-protected API

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

bento
1