chat-ui README

The project's README from github.com/huggingface/chat-ui. As one markdown file: README.md.

Chat UI

Chat UI repository thumbnail

A chat interface for LLMs. It is a SvelteKit app and it powers the HuggingChat app on hf.co/chat.

  1. Quickstart
  2. Database Options
  3. Launch
  4. Optional Docker Image
  5. Extra parameters
  6. Building

[!NOTE] Chat UI only supports OpenAI-compatible APIs via OPENAI_BASE_URL and the /models endpoint. Provider-specific integrations (legacy MODELS env 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

Quickstart

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.

Database Options

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_URL is not set, Chat UI falls back to an embedded MongoDB that persists to ./db.

MongoDB Atlas (managed)

  1. Create a free cluster at mongodb.com.
  2. Add your IP (or 0.0.0.0/0 for development) to the network access list.
  3. Create a database user and copy the connection string.
  4. Paste that string into 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.

Local MongoDB (container)

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.

Launch

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.

Optional Docker Image

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.

Extra parameters

Theming

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=

Models

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.

LLM Router (Optional)

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.

When you select Omni in the UI, Chat UI will:

Tool and multimodal shortcuts:

MCP Tools (Optional)

Chat UI can call tools exposed by Model Context Protocol (MCP) servers and feed results back to the model using OpenAI function calling. You can preconfigure trusted servers via env, let users add their own, and optionally have the Omni router auto‑select a tools‑capable model.

Configure servers (base list for all users):

# JSON array of servers: name, url, optional headers
MCP_SERVERS=[
  {"name": "Web Search (Exa)", "url": "https://mcp.exa.ai/mcp"},
  {"name": "Hugging Face MCP Login", "url": "https://hf.co/mcp?login"}
]

# Forward the signed-in user's Hugging Face token to the official HF MCP login endpoint
# when no Authorization header is set on that server entry.
MCP_FORWARD_HF_USER_TOKEN=true

Enable router tool path (Omni):

Use tools in the UI:

Per‑model overrides:

Building

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

chat-ui (huggingface/chat-ui)

Searching Database…

这是什么?Chat UI 是开源的聊天界面,为 Hugging Face 的 HuggingChat 应用(hf.co/chat)提供支持。它是一个可以自行部署的 SvelteKit 网页应用,用于通过任意兼容 OpenAI 的 API 与大语言模型对话。
这是我可以导入的库,还是需要单独运行的应用?这是一个用 SvelteKit 构建的独立自部署网页应用,不是库。你可以通过 npm 或 Docker 部署它,并将其指向一个兼容 OpenAI 的模型接口地址。
怎么把它跑起来?创建一个 .env.local 文件,其中 OPENAI_BASE_URL 和 OPENAI_API_KEY 指向兼容 OpenAI 的接口(例如 HF Inference Providers、llama.cpp、Ollama、OpenRouter),然后运行 npm install 和 npm run dev。
除了 Node.js,我还需要准备什么?数据库、API 密钥之类的?你需要一个模型所用的、兼容 OpenAI 的 API 密钥或接口地址,还需要 MongoDB 6/7 用于存储聊天记录、用户和设置;如果跳过 MONGODB_URL,程序会退回到保存在 ./db 中的内置 MongoDB,便于本地快速测试。
它是否仍支持 GGUF 或内置网页搜索等特定服务商的集成?不再支持。旧的特定服务商功能(旧的 MODELS 环境变量、GGUF 发现、嵌入、网页搜索辅助工具)已被移除,目前只支持兼容 OpenAI 的 API;不过,旧功能集仍保留在项目的 legacy 分支中。
Omni 模型路由器是什么?Omni 是一个虚拟模型别名,它通过本地启发式规则为每条消息选择最佳路由:图片输入交给多模态模型,启用 MCP 工具的请求交给智能体模型,其余请求使用默认模型;如果某个路由失败,会自动切换到备用方案。
Chat UI 能调用外部工具吗?可以,通过 Model Context Protocol(MCP)服务器实现。你可以预先配置受信任的服务器,也可以让用户添加自己的服务器;模型通过 OpenAI 函数调用来使用这些工具,结果会直接显示在聊天中。
我能为自己的部署更换界面品牌吗?可以。PUBLIC_APP_NAME 和 PUBLIC_APP_ASSETS 等环境变量可用来修改应用名称以及 logo 和网站图标;PUBLIC_APP_DATA_SHARING 则可以在用户设置中添加一个数据共享开关(需用户自行开启)。
有现成的 Docker 镜像吗?有。chat-ui-db 镜像已在容器内集成了 MongoDB,因此你只需一条 Docker 命令即可运行整套服务,并通过 -e 参数传入环境变量。
Size
16.6 MB
Stars
11K
Age
3y
Commits · 90 Days