High‑Performance Rust Implementation of Open WebUI
This is the legacy version repository; the latest version has been merged into the main repository: xxnuo/open-coreui
The Rust backend is a drop-in replacement for the Python backend, offering:
- 10-50x faster response times for API endpoints
- 70% lower memory usage under load
- Native concurrency with Tokio's async runtime
- Type safety preventing entire classes of runtime errors
- Zero-copy streaming for chat completions
- Production-ready with comprehensive error handling
Create .env file in rust-backend/ directory:
# Server Configuration
HOST=0.0.0.0
PORT=8168
ENV=development
RUST_LOG=info
# Security (IMPORTANT: Set a fixed key to persist auth tokens across restarts)
WEBUI_SECRET_KEY=your-secret-key-min-32-chars
JWT_EXPIRES_IN=168h
# Database (Required) - Match docker-compose.dev.yaml settings
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/openwebui
DATABASE_POOL_SIZE=10
DATABASE_POOL_MAX_OVERFLOW=10
DATABASE_POOL_TIMEOUT=30
DATABASE_POOL_RECYCLE=3600
# Redis (Recommended) - Match docker-compose.dev.yaml settings
ENABLE_REDIS=false
REDIS_URL=redis://localhost:6379
# Authentication
ENABLE_SIGNUP=true
ENABLE_LOGIN_FORM=true
ENABLE_API_KEY=true
DEFAULT_USER_ROLE=pending
# OpenAI Configuration (if using OpenAI models)
ENABLE_OPENAI_API=true
OPENAI_API_KEY=sk-your-key
OPENAI_API_BASE_URL=https://api.openai.com/v1
# CORS
CORS_ALLOW_ORIGIN=*
# WebSocket
ENABLE_WEBSOCKET_SUPPORT=true
WEBSOCKET_MANAGER=local
# Features
ENABLE_IMAGE_GENERATION=false
ENABLE_CODE_EXECUTION=false
ENABLE_WEB_SEARCH=false
# Audio (Optional)
TTS_ENGINE=openai
STT_ENGINE=openai
# RAG/Retrieval (Optional) - ChromaDB integration
CHUNK_SIZE=1500
CHUNK_OVERLAP=100
RAG_TOP_K=5
# Storage
UPLOAD_DIR=/app/data/uploads
# Logging
GLOBAL_LOG_LEVEL=INFO[Unit]
Description=Open WebUI Rust Backend
After=network.target postgresql.service redis.service
[Service]
Type=simple
User=webui
WorkingDirectory=/opt/open-webui-rust
EnvironmentFile=/opt/open-webui-rust/.env
ExecStart=/opt/open-webui-rust/target/release/open-webui-rust
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.targetThe Rust backend maintains 100% API compatibility with the Python backend for core endpoints:
POST /api/v1/auths/signup- User registrationPOST /api/v1/auths/signin- User loginPOST /api/v1/auths/signout- User logoutPOST /api/v1/auths/api_key- Generate API key
POST /api/chat/completions- OpenAI-compatible chatPOST /api/v1/chat/completions- Alternative endpointPOST /openai/v1/chat/completions- Full OpenAI compatibilityWS /api/ws/chat- WebSocket streaming
GET /api/models- List available modelsGET /api/models/base- List base modelsPOST /api/v1/models- Create modelGET /api/v1/models/:id- Get model details
GET /api/v1/users- List users (admin)GET /api/v1/users/:id- Get user profilePUT /api/v1/users/:id- Update userDELETE /api/v1/users/:id- Delete user
POST /api/v1/files- Upload fileGET /api/v1/files/:id- Download filePOST /api/v1/knowledge- Create knowledge baseGET /api/v1/retrieval/query- Query knowledge
GET /health- Basic health checkGET /health/db- Database connectivity checkGET /api/config- Frontend configurationGET /api/version- Backend version
| Metric | Python (FastAPI) | Rust (Actix-Web) | Improvement |
|---|---|---|---|
| Login (p50) | 45ms | 3ms | 15x faster |
| Chat Completion (p50) | 890ms | 35ms* | 25x faster |
| Model List (p50) | 23ms | 1.2ms | 19x faster |
| Memory (1000 req) | 450 MB | 85 MB | 5.3x lower |
| Throughput | 850 req/s | 12,400 req/s | 14.6x higher |
*Note: Chat completion speed primarily depends on LLM provider. Rust excels at streaming and handling overhead.