A fast, secure, self-hostable chat application built with Rust, TypeScript, and React. Chat with multiple AI providers using your own API keys, with real-time streaming built-in.
Demo link: https://rs-chat.fly.dev/ (
- Multiple AI Providers: Chat with AI models from OpenAI, Anthropic, and OpenRouter
- Streaming: Streams responses using SSE (Server-Sent Events)
- Concurrent Streaming: Seamlessly switch between multiple AI conversations streamed at the same time
- Resumable Conversations: Resume the conversation if your connection is lost or the page is refreshed
- Code Highlighting: Beautiful syntax highlighting for code blocks using
rehype-highlight
- Dark Mode: Dark/light theme support
- Responsive Design: Mobile-friendly layout
- Search Chats: Full-text search of chat session titles and messages
- Fast and Memory Efficient: Rust backend using the Rocket framework
- Users & Authentication: Login via OAuth providers (Google, GitHub, etc.), custom OIDC, and SSO header authentication
- API Key Access and OpenAPI Docs: API key access and documentation at
/api/docs
for developers to integrate with RsChat - Fully Type-Safe: End-to-end type safety with auto-generated client from OpenAPI spec
- Smart Titles: Auto-generation of chat titles
- Smart Scrolling: Auto-scroll during streaming and when opening previous chats
- Secure Key Storage: Your API keys are saved and encrypted
Backend: Rust with Rocket framework, PostgreSQL, Redis
Frontend: React 19, TypeScript, Vite, TanStack Router, Tailwind CSS, shadcn/ui
Type Safety: OpenAPI spec generation with rocket_okapi, and auto-generated TS client using openapi-typescript
rs-chat/
βββ server/ # Rust backend
β βββ src/
β β βββ api/ # API route handlers
β β βββ auth/ # Authentication services
β β βββ db/ # Database models and services
β β βββ provider/ # AI provider integrations
β β βββ utils/ # Utility functions
β β βββ config.rs # Reading configuration / env variables
β β βββ lib.rs # Server setup
β β βββ main.rs # Server entry point
β β βββ ... # Other modules
β βββ migrations/ # Database migrations
β βββ Cargo.toml # Rust dependencies
βββ web/ # Vite / React frontend
β βββ src/
β β βββ components/ # React components
β β βββ routes/ # TanStack Router routes
β β βββ lib/ # Utilities and API client
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
βββ docker-compose.yml # Docker Compose file for development
βββ Dockerfile # Dockerfile to build RsChat as a container
After logging in:
- Click on name in top-left, and go to API Keys
- Add your provider API keys:
- OpenAI: Get your key from OpenAI
- Anthropic: Get your key from Anthropic Console
- OpenRouter: Get your key from OpenRouter
Your API keys are encrypted and stored in the database.
- Rust >= 1.85 (Install Rust)
- Node.js >= 20 with pnpm (Install pnpm)
- Docker and Docker Compose (for databases)
-
Clone the repository
git clone https://github.com/fa-sharp/rs-chat.git cd rs-chat
-
Start development databases
docker compose up -d db redis
-
Set up the backend
cd server cp .env.example .env # Edit with your settings cargo run # This will run migrations automatically
-
Set up the frontend (in a new terminal)
cd web pnpm install pnpm dev
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/api/docs
When the backend API changes, regenerate the TypeScript client:
cd web
pnpm run gen-api
cd server
# Create new migration
diesel migration generate migration_name
# Run migrations
cargo run # Migrations run automatically on startup
You'll need an environment with PostgreSQL and Redis (or Redis-compatible database).
services:
rschat:
image: ghcr.io/fa-sharp/rs-chat:latest
# ports:
# - "8080:8080"
environment:
RUST_LOG: warn # 'info' or 'debug' for more logs
RS_CHAT_SERVER_ADDRESS: https://mydomain.com # where you're hosting the app
RS_CHAT_DATABASE_URL: postgres://user:pass@mypostgres/mydb # Your PostgreSQL URL
RS_CHAT_REDIS_URL: redis://myredis:6379 # Your Redis URL
RS_CHAT_SECRET_KEY: your-secret-key-for-encryption # 64-character hex string
## For GitHub login: callback URL should be {your_server_address}/api/auth/login/github/callback
# RS_CHAT_GITHUB_CLIENT_ID: your-github-client-id
# RS_CHAT_GITHUB_CLIENT_SECRET: your-github-client-secret
## Similar config for other OAuth providers - see server/src/auth/oauth/ folder
# RS_CHAT_DISCORD_CLIENT_ID: your-discord-client-id
# ...
## For SSO header auth - see server/src/auth/sso_header.rs for all config options
# RS_CHAT_SSO_HEADER_ENABLED: true
# RS_CHAT_SSO_USERNAME_HEADER: X-Remote-User
# ...
## For running code on a remote Docker host
# DOCKER_HOST: tcp://remote-docker-host:port
# DOCKER_TLS_VERIFY: 1
# DOCKER_CERT_PATH: /certs
volumes:
## For running code on local Docker host
# - /var/run/docker.sock:/var/run/docker.sock:ro
## Certificates for remote Docker host
# - ./path/to/certs:/certs
- Your Keys, Your Control: You provide and manage your own AI provider API keys
- Encrypted Storage: API keys are encrypted using AES-GCM
- Open Source: Full transparency - audit the code yourself
- Create an issue or discussion to discuss the idea with maintainers
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.
- TanStack and Vite for great JS tooling and libraries
- Rocket for the amazing Rust web framework
- shadcn and shadcn-chat for the UI
- Many, many other open-source maintainers and contributors that make this project possible
β€οΈ Built with the Zed editor, with help from Claude.