The open source codebase powering HuggingChat
翻訳待ち
Loading the full README.
Read the full README ↗A chat interface for LLMs. It is a SvelteKit app and it powers the HuggingChat app on hf.co/chat.
[!NOTE] Chat UI only supports OpenAI-compatible APIs via
OPENAI_BASE_URLand the/modelsendpoint. Provider-specific integrations (legacyMODELSenv var, GGUF discovery, embeddings, web-search helpers, etc.) are removed, but any service that speaks the OpenAI protocol (llama.cpp server, Ollama, OpenRouter, etc.) will work by default.
[!NOTE] The old version is still available on the legacy branch
Chat UI speaks to OpenAI-compatible APIs only. The fastest way to get running is with the Hugging Face Inference Providers router plus your personal Hugging Face access token.
Step 1 – Create .env.local:
OPENAI_BASE_URL=https://router.huggingface.co/v1
OPENAI_API_KEY=hf_************************
OPENAI_API_KEY can come from any OpenAI-compatible endpoint you plan to call. Pick the combo that matches your setup and drop the values into .env.local:
| Provider | Example OPENAI_BASE_URL | Example key env |
|---|---|---|
| Hugging Face Inference Providers router | https://router.huggingface.co/v1 | OPENAI_API_KEY=hf_xxx (or HF_TOKEN legacy alias) |
llama.cpp server (llama.cpp --server --api) | http://127.0.0.1:8080/v1 | OPENAI_API_KEY=sk-local-demo (any string works; llama.cpp ignores it) |
| Ollama (with OpenAI-compatible bridge) | http://127.0.0.1:11434/v1 | OPENAI_API_KEY=ollama |
| OpenRouter | https://openrouter.ai/api/v1 | OPENAI_API_KEY=sk-or-v1-... |
| Poe | https://api.poe.com/v1 | OPENAI_API_KEY=pk_... |
Check the root .env template for the full list of optional variables you can override.
Step 2 – Install and launch the dev server:
git clone https://github.com/huggingface/chat-ui
cd chat-ui
npm install
npm run dev -- --open
You now have Chat UI running locally. Open the browser and start chatting.
Chat history, users, settings, files, and stats all live in MongoDB. You can point Chat UI at any MongoDB 6/7 deployment.
[!TIP] For quick local development, you can skip this section. When
MONGODB_URLis not set, Chat UI falls back to an embedded MongoDB that persists to./db.
0.0.0.0/0 for development) to the network access list.MONGODB_URL in .env.local. Keep the default MONGODB_DB_NAME=chat-ui or change it per environment.Atlas keeps MongoDB off your laptop, which is ideal for teams or cloud deployments.
If you prefer to run MongoDB in a container:
docker run -d -p 27017:27017 --name mongo-chatui mongo:latest
Then set MONGODB_URL=mongodb://localhost:27017 in .env.local.
After configuring your environment variables, start Chat UI with:
npm install
npm run dev
The dev server listens on http://localhost:5173 by default. Use npm run build / npm run preview for production builds.
The chat-ui-db image bundles MongoDB inside the container:
docker run \
-p 3000:3000 \
-e OPENAI_BASE_URL=https://router.huggingface.co/v1 \
-e OPENAI_API_KEY=hf_*** \
-v chat-ui-data:/data \
ghcr.io/huggingface/chat-ui-db:latest
All environment variables accepted in .env.local can be provided as -e flags.
You can use a few environment variables to customize the look and feel of chat-ui. These are by default:
PUBLIC_APP_NAME=ChatUI
PUBLIC_APP_ASSETS=chatui
PUBLIC_APP_DESCRIPTION="Making the community's best AI chat models available to everyone."
PUBLIC_APP_DATA_SHARING=
PUBLIC_APP_NAME The name used as a title throughout the app.PUBLIC_APP_ASSETS Is used to find logos & favicons in static/$PUBLIC_APP_ASSETS, current options are chatui and huggingchat.PUBLIC_APP_DATA_SHARING Can be set to 1 to add a toggle in the user settings that lets your users opt-in to data sharing with models creator.Models are discovered from ${OPENAI_BASE_URL}/models, and you can optionally override their metadata via the MODELS env var (JSON5). Legacy provider‑specific integrations and GGUF discovery are removed. Authorization uses OPENAI_API_KEY (preferred). HF_TOKEN remains a legacy alias.
Chat UI can perform server-side smart routing using a local heuristic — no separate router service or selection model is called. The UI exposes a virtual model alias called "Omni" (configurable) that, when selected, chooses the best route/model for each message: image inputs go to a multimodal route, MCP-tool-enabled requests go to an agentic route, and everything else goes to a default route.
This is the beginning of the README. Read the rest at the original. Read the full README ↗