LibreChat is an open-source chat interface that brings many AI models together in one ChatGPT-style UI: OpenAI, Anthropic Claude, Google Gemini, Azure OpenAI, Mistral, OpenRouter, Groq, local models via Ollama, and any OpenAI-compatible API. Self-host it to give your team one place to chat with AI, using your own API keys, with conversations stored on your server.
Comparing options? See Open WebUI, which focuses on local models.
Why self-host it?
- Pay per use via API keys, instead of per-seat subscriptions.
- Switch models mid-conversation, and compare answers.
- Data control: conversations live in your database. Prompts still go to whichever provider you choose.
- Team features: user accounts, presets, agents, file uploads and RAG over documents.
Requirements
- 2 vCPU and 4 GB RAM (more if you enable RAG or the meilisearch-based search).
- Docker and Docker Compose. See install Docker.
- API keys for the providers you want.
Hosting location matters for some providers’ availability and latency. For AI APIs from Asia, VPS.DO’s Tokyo VPS plans support access to major AI APIs. See Japan VPS.
Install
git clone https://github.com/danny-avila/LibreChat.git /opt/librechat
cd /opt/librechat
cp .env.example .env
Edit .env. Key settings:
DOMAIN_CLIENT=https://chat.example.com
DOMAIN_SERVER=https://chat.example.com
ALLOW_REGISTRATION=false # set true only to create the first account, then turn off
ALLOW_SOCIAL_LOGIN=false
CREDS_KEY=<64 hex chars> # encrypts stored user API keys
CREDS_IV=<32 hex chars>
JWT_SECRET=<random>
JWT_REFRESH_SECRET=<random>
OPENAI_API_KEY=sk-... # or "user_provided" to let each user enter their own
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_KEY=...
LibreChat’s docs include a credentials generator for the secrets. Store .env with chmod 600. See secrets management.
Start it:
docker compose up -d
The default compose file runs the API and client, plus MongoDB, Meilisearch (conversation search), and the RAG API with a vector DB (pgvector).
HTTPS with Nginx
Bind the app port to localhost (via docker-compose.override.yml), then:
server {
server_name chat.example.com;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:3080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off; # stream tokens as they arrive
proxy_read_timeout 300s;
}
# listen 443 ssl; certbot --nginx -d chat.example.com
}
proxy_buffering off matters, because LibreChat streams responses via server-sent events. See Let’s Encrypt.
Users
Create your account with registration on, then disable registration (ALLOW_REGISTRATION=false), and add users via the CLI:
docker compose exec api npm run create-user
Or use SSO via OIDC (Keycloak, Authentik, Google Workspace). See Keycloak.
Custom endpoints: librechat.yaml
Add OpenAI-compatible providers (OpenRouter, Groq, Mistral, DeepSeek, local Ollama or LocalAI) in librechat.yaml:
version: 1.2.1
endpoints:
custom:
- name: "Ollama"
apiKey: "ollama"
baseURL: "http://host.docker.internal:11434/v1/"
models:
default: ["llama3.1:8b"]
fetch: true
titleConvo: true
Mount it into the container (per the docs), and restart. See LocalAI.
Features worth enabling
- File uploads and RAG: chat with PDFs and documents. Embeddings are stored in the vector DB. See vector databases.
- Agents and tools: web search (via SearXNG), code interpreter (external service), image generation and MCP servers. See SearXNG.
- Presets for repeated prompts, and per-model settings.
Costs and limits
API usage is billed by the providers. Set token balance limits per user in LibreChat (balance settings), and spending limits at each provider. Monitor usage dashboards.
Backups and updates
- Back up MongoDB (
mongodump), the vector DB, uploaded files, and.envpluslibrechat.yaml. See MongoDB backup and backup strategy. - Update with
git pull && docker compose pull && docker compose up -d. Read the changelog, since config formats evolve quickly. See updating self-hosted apps.
Quick reference
| Item | Value |
|---|---|
| Port | 3080 |
| Main config | .env |
| Extra endpoints | librechat.yaml |
| Create user | docker compose exec api npm run create-user |
| Disable signups | ALLOW_REGISTRATION=false |
Related: Open WebUI with Ollama and API security.