chat-ui
The open source codebase powering HuggingChat
The open-source web app behind HuggingChat, run your own AI chat interface that connects to any OpenAI-compatible model endpoint, including local models via Ollama or llama.cpp.
Chat UI is the open-source code behind HuggingChat, Hugging Face's publicly available chat assistant website. If you want to run your own chat interface for AI models, this is the codebase you would use. It is a web application built with SvelteKit, a framework for building websites, and it stores conversation history and user data in a MongoDB database.
The application connects to AI models through any API that follows the OpenAI protocol. That is a widely adopted standard, so it works with Hugging Face's own model hosting, with locally-run models through tools like Ollama or llama.cpp, and with third-party services like OpenRouter. You configure which endpoint to use by setting two environment variables: the API address and an access key. No code changes are needed to swap between providers.
Setting it up locally takes a few minutes. You clone the repository, create a small configuration file with your API credentials, install dependencies with npm, and run the development server. For the database, if you do not supply a MongoDB connection string, the app starts an embedded database automatically so you can get going without extra setup. For more permanent deployments, you can point it at a managed MongoDB service or run MongoDB in a Docker container.
A Docker image is also available that bundles everything together, including the database, so you can launch the whole stack with a single command and a couple of environment variables.
The README notes that the current version removed older provider-specific integrations in favor of the unified OpenAI-compatible approach. A legacy branch preserves the previous version for anyone who relied on the older configuration style.
Where it fits
- Self-host a full chat interface for any AI model using just two environment variables to point at your chosen API endpoint
- Run a local AI chat app in Docker with a single command, the image includes an embedded database so nothing else is needed
- Build a customized internal chat tool for your company by cloning this codebase and swapping in your own model endpoint