# Hugging Face Chat UI

> Self-hosted chat interface for open LLMs, the SvelteKit app behind HuggingChat

- Category: App UIs & Builders / Chat UIs
- Language: TypeScript
- Repository: https://github.com/huggingface/chat-ui
- Website: https://huggingface.co/chat
- Canonical page: https://ai-tldr.dev/tools/hugging-face-chat-ui/

## In short

Hugging Face Chat UI is Self-hosted chat interface for open LLMs, the SvelteKit app behind HuggingChat. It gives you a web chat interface in front of large language models, and you run it on your own machine or server. It sits in the Chat UIs category of the App UIs & Builders tools and is open-source, written in TypeScript.

## Overview

Chat UI is the open-source SvelteKit application that powers HuggingChat at hf.co/chat. It gives you a web chat interface in front of large language models, and you run it on your own machine or server.

It talks to any OpenAI-compatible API through the OPENAI_BASE_URL and /models endpoints. That means it works with the Hugging Face Inference Providers router, a local llama.cpp server, Ollama, OpenRouter, and similar services without provider-specific code. Chat history, users, settings, and files are stored in MongoDB.

It fits the Chat UIs category as a full front end you host yourself, rather than a hosted product. It suits developers and teams who want a private chat app over open models, with control over branding, the model list, and where data is stored.

## What it does

- Works with any OpenAI-compatible API: Hugging Face router, llama.cpp, Ollama, OpenRouter, Poe, and others
- Discovers available models from the ${OPENAI_BASE_URL}/models endpoint, with optional metadata overrides via the MODELS env var
- Stores chat history, users, settings, files, and stats in MongoDB, with an embedded fallback that persists to ./db for local dev
- Theming through environment variables (app name, assets, description, data-sharing toggle)
- Optional server-side LLM routing via an 'Omni' alias that sends image inputs, MCP-tool requests, and other messages to configured routes
- Ships an optional chat-ui-db Docker image that bundles MongoDB inside the container

## Getting started

Chat UI speaks to OpenAI-compatible APIs only. The fastest start uses the Hugging Face Inference Providers router with your personal access token.

1. Create .env.local

   Point Chat UI at an OpenAI-compatible endpoint and supply a matching key. This example uses the Hugging Face router.

```text
OPENAI_BASE_URL=https://router.huggingface.co/v1
OPENAI_API_KEY=hf_************************
```

2. Install and launch the dev server

   Clone the repo, install dependencies, and start the dev server. It opens in your browser so you can start chatting.

```bash
git clone https://github.com/huggingface/chat-ui
cd chat-ui
npm install
npm run dev -- --open
```

3. Database (optional for local dev)

   When MONGODB_URL is not set, Chat UI falls back to an embedded MongoDB that persists to ./db. To run MongoDB in a container, start one and point Chat UI at it.

```bash
docker run -d -p 27017:27017 --name mongo-chatui mongo:latest
```

4. Build for production

   Use the build and preview scripts to run a production build instead of the dev server.

```bash
npm run build
npm run preview
```

## When to use it

- Self-host a private chat app over open models from the Hugging Face Hub for a team or organization
- Put a browser chat interface in front of a local llama.cpp server or Ollama instance during development
- Run a branded internal assistant where chat history and user data stay in your own MongoDB
- Deploy a containerized chat app quickly using the chat-ui-db Docker image that bundles MongoDB
