Every answer. Cited sources. Your model. Your data. Your rules.
If OpenChat is useful to you, a ⭐ on the repo helps others find it — thank you! We're open to new ideas, feature requests, and bug reports — open an issue and it will be handled accordingly.
Tired of AI that confidently makes things up? OpenChat grounds every response in real, verifiable sources — and you own everything: the model, the data, the deployment.
Overview![]() |
Chat — cited sources![]() |
Settings![]() |
Most AI chat tools give you a great experience — until they change it. You have no say in the model, the personality, or where your conversations go.
OpenChat flips that:
| OpenChat | Typical SaaS AI | |
|---|---|---|
| Pick your model | ✅ Any provider | ❌ Locked in |
| Own your data | ✅ Your database | ❌ Their servers |
| Cited sources | ✅ Every response | ❌ Rarely |
| Self-hostable | ✅ Docker / Cloud | ❌ Subscription |
| Customise personality | ✅ Full control | ❌ Fixed prompts |
- Multi-provider LLM — Groq, OpenAI, Anthropic, Google Gemini, Ollama — swap with one env var, zero code changes
- Cited sources — every AI response includes a collapsible sources banner; no unverified claims
- Persistent sessions — full chat history in PostgreSQL, MySQL, or SQLite; survives restarts
- Real-time streaming — responses stream live with a typing cursor indicator
- Settings UI — change provider, model, API key, and database from the browser — no restart needed
- Configurable personality — tune the AI's tone, focus, and rules via
LLM_SYSTEM_PROMPT - Dark-mode UI — clean, minimal interface built with Next.js 16 and Tailwind CSS v4
- Production-ready — Docker, Cloud Foundry, GCP, AWS, and Azure deployment guides included
Runs OpenChat with Gemma 3 4B via Ollama and SQLite. Nothing to sign up for.
Requirements: Node.js ≥ 20, npm, curl
git clone https://github.com/SentorLabs/openchat.git
cd openchat
./start.shThe script will:
- Install Ollama if not present
- Pull the Gemma 3 4B model (~3 GB, one-time)
- Write a
.env.localwith SQLite + Ollama config - Start OpenChat at http://localhost:3000
Swap in any provider or database via
.env.localor the Settings UI.
git clone https://github.com/SentorLabs/openchat.git
cd openchat
npm installcp .env.example .env.localLLM_PROVIDER=groq # groq | openai | anthropic | gemini | ollama
LLM_MODEL=llama-3.3-70b-versatile
LLM_API_KEY=your_api_key_here
DATABASE_URL=postgresql://postgres:password@localhost:5432/openchatcreatedb openchat # auto-creates tables on first run
npm run devOpen http://localhost:3000. That's it.
| Provider | LLM_PROVIDER |
Example model | Free tier |
|---|---|---|---|
| Groq | groq |
llama-3.3-70b-versatile |
✅ Yes |
| OpenAI | openai |
gpt-4o |
❌ No |
| Anthropic | anthropic |
claude-opus-4-6 |
❌ No |
| Google Gemini | gemini |
gemini-2.0-flash |
✅ Yes |
| Ollama (local) | ollama |
llama3.2 |
✅ Free |
# Coding assistant
LLM_SYSTEM_PROMPT="You are a senior software engineer. Answer only technical questions with code examples."
# Strict research analyst
LLM_SYSTEM_PROMPT="You are a research analyst. Always cite primary sources. Never state unverified facts."
# Customer support agent
LLM_SYSTEM_PROMPT="You are a support agent for Acme Corp. Only answer questions about our product."No redeploy needed — update the env var and restart.
Docker
docker build -t openchat .
docker run -p 3000:3000 \
-e LLM_PROVIDER=groq \
-e LLM_MODEL=llama-3.3-70b-versatile \
-e LLM_API_KEY=your_key \
-e DATABASE_URL=postgresql://... \
openchatSAP BTP Cloud Foundry
See DEPLOY.md for the full guide.
cf push -f deploy-postgres.yml
cf create-user-provided-service openchat-db -p '{"uri":"postgresql://..."}'
cf push -f manifest.yml
cf add-network-policy openchat --destination-app postgres-db --port 5432 --protocol tcp
cf set-env openchat LLM_PROVIDER groq
cf restage openchatGCP / AWS / Azure
See DEPLOY.md for Cloud Run, App Runner, and Container Apps guides.
src/
├── app/
│ ├── api/
│ │ ├── chat/route.ts # Streaming chat endpoint
│ │ ├── sessions/route.ts # List & create sessions
│ │ └── sessions/[id]/
│ │ ├── route.ts # Delete session
│ │ └── messages/route.ts # Load session messages
│ ├── about/page.tsx
│ ├── releases/page.tsx
│ ├── page.tsx # Main chat UI
│ └── globals.css
├── components/
│ ├── Nav.tsx # Top navigation bar
│ ├── Sidebar.tsx # Session list panel
│ └── SourcesBanner.tsx # Collapsible sources banner
└── lib/
├── db.ts # Multi-database adapter (PG / MySQL / SQLite)
├── llm.ts # Unified multi-provider LLM adapter
├── sources.ts # Parse & strip [SOURCES] blocks
└── types.ts # Shared TypeScript interfaces
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript 5 |
| Styling | Tailwind CSS v4 |
| Database | PostgreSQL · MySQL · SQLite |
| LLM providers | Groq · OpenAI · Anthropic · Gemini · Ollama |
| Runtime | Node.js ≥ 20 |
OpenChat is built for the community. If you run your own AI assistant, you know what's missing — and PRs are welcome.
- New LLM providers — Mistral, Cohere, Together AI
- UI improvements — markdown rendering, code highlighting
- Export features — download chat history as PDF or Markdown
- Auth support — multi-user mode with authentication
- Docker Compose — ready-to-run compose file with Postgres
git checkout -b feat/your-feature
# make your changes
npm run test && npm run build
# open a pull requestOpen an issue with: steps to reproduce · expected vs actual · your LLM_PROVIDER · Node.js version.
View schema (auto-created on first run)
CREATE TABLE sessions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
title TEXT NOT NULL DEFAULT 'New Chat',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE messages (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
session_id UUID NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
role TEXT NOT NULL CHECK (role IN ('user','assistant')),
content TEXT NOT NULL,
sources JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);Apache 2.0 — free to use, modify, and distribute, including for commercial use. See LICENSE.
Take control of your AI experience.



