chat-ui is a chat interface for large language models, built with SvelteKit, and is the open-source codebase of the HuggingChat application.
Purpose: to provide a self-hostable chat frontend for LLMs and support connecting to any OpenAI-compatible API.
Main capabilities:
- Communicates with OpenAI-compatible APIs only via OPENAI_BASE_URL and the /models endpoint, supporting services such as llama.cpp server, Ollama, and OpenRouter.
- Chat history, users, settings, files, and statistics are stored in MongoDB 6/7; when MONGODB_URL is not set, embedded MongoDB is used and persisted to ./db.
- Provides an optional Docker image chat-ui-db with MongoDB bundled in the container.
- App name, assets, data-sharing toggle, and other appearance and behavior can be customized via environment variables.
- Models are discovered from ${OPENAI_BASE_URL}/models, and metadata can be overridden via the MODELS environment variable (JSON5).
- Optional server-side smart routing: the UI exposes a virtual model alias "Omni", which locally selects a route/model based on request signals (image input, MCP tools enabled, etc.), supporting route policy JSON configuration, fallback models, and multimodal and tool fast paths.
- Optional MCP tool calling: supports preconfigured trusted MCP servers, user-added servers, health checks, and returns tool results to the model via OpenAI function calling; supports per-model overrides of tool calling and multimodal input settings.
- Experimental ML Intern mode: plans and runs machine learning work on the Hugging Face Hub, including reproducing papers, fine-tuning and evaluating models, building datasets, deploying demos as Spaces, and running scripts with Hugging Face Jobs and sandboxes within a user-set compute budget.
Usage:
- Create .env.local and set variables such as OPENAI_API_KEY.
- Install dependencies and start the development server, which by default listens on http://localhost:5173;生产构建使用 npm run build / npm run preview.
- Configure MongoDB (Atlas or a local container) as needed and set MONGODB_URL.
- Optionally configure variables such as LLM_ROUTER_ROUTES_PATH to enable smart routing, or configure MCP servers to enable tool calling.
Use cases: developers, teams, or cloud deployment environments that need a self-hosted LLM chat interface; scenarios that want unified access to multiple OpenAI-compatible backends; chat applications that need tool calling or multimodal input.
Limitations: only OpenAI-compatible APIs are supported; legacy provider-specific integrations, GGUF discovery, embeddings, web search assistance, etc. have been removed; smart routing uses local heuristics and does not call an independent routing service or model selector; ML Intern is an experimental feature; some configurations require creating JSON files yourself, and the repository does not include example files.