AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Running HuggingChat with Self-Hosted Open-Source Models Outside the Hugging Face Cloud

Ivan L. Latham · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

You cannot point the public web interface at huggingface.co/chat to an on-premises model running in your private data center. Hugging Face operates the public HuggingChat service as a hosted cloud SaaS; it provides no interface setting to input arbitrary local URLs or bypass its managed infrastructure.

If you want the HuggingChat experience running against self-hosted open-source models completely outside the Hugging Face cloud, the answer is still yes. Hugging Face built HuggingChat on top of Chat UI (huggingface/chat-ui), an open-source codebase licensed under Apache-2.0. By self-hosting Chat UI alongside a private inference engine like vLLM, Ollama, or Text Generation Inference (TGI), technical teams can run an entirely isolated, air-gapped HuggingChat interface on internal hardware.

At 365Finds, we evaluate enterprise LLM interfaces not just on visual polish, but on how easily engineering teams can tear away cloud dependencies. Here is how HuggingChat’s architecture splits apart, how to deploy it on private infrastructure, and where 365Finds stands on choosing Chat UI over alternative open-source frontends.


The Architecture: How Self-Hosted HuggingChat Works

The public HuggingChat site is essentially three components glued together:

  1. Frontend & Middleware (Chat UI): A SvelteKit application handling authentication, conversations, model switching, web search routing, and custom assistants.
  2. Persistence Layer (MongoDB): Stores chat threads, user accounts, system prompts, and shared conversations.
  3. Inference Backend: The actual model computation layer. On huggingface.co/chat, this calls Hugging Face's cloud router. In your private setup, this becomes your own inference server exposing an OpenAI-compatible HTTP endpoint.
+-----------------------------------------------------------+
|                      User Browser                         |
+-----------------------------+-----------------------------+
                              |
                              v
+-----------------------------------------------------------+
|             Hugging Face Chat UI (Self-Hosted)            |
|       - SvelteKit App (Docker / Node.js)                  |
|       - Session & Assistant Management                     |
+--------------+-----------------------------+--------------+
               |                             |
               v                             v
+-----------------------------+  +--------------------------+
|       MongoDB Database      |  | Private Inference Server |
|  - Conversations & History  |  |  - vLLM / TGI / Ollama   |
|  - Custom Assistants        |  |  - OpenAI-compatible API |
+-----------------------------+  +--------------------------+

Because modern releases of Chat UI support native OpenAI-compatible API schemas and dynamic model discovery via the standard /models endpoint, connecting it to local open-source models no longer requires custom adapters or legacy Hugging Face Hub tokens.


Step-by-Step: Deploying HuggingChat with Local Models

Step 1: Launch Your Private Inference Engine

Your private inference engine must serve an OpenAI-compatible API. Two engines stand out depending on your infrastructure:

Step 2: Spin Up MongoDB

Chat UI requires MongoDB to persist chat histories and user preferences. In a Docker environment, run:

docker run -d \
  --name chat-ui-db \
  -p 27017:27017 \
  -v mongo_data:/data/db \
  mongo:latest

Step 3: Configure and Run Chat UI

You can deploy Chat UI either using the official Docker image or by cloning the repository. For containerized deployments, define your environment variables to point directly to your private inference engine and MongoDB instance.

Create a minimal docker-compose.yml:

version: '3.8'

services:
  mongo:
    image: mongo:latest
    restart: unless-stopped
    volumes:
      - mongo_data:/data/db

  chat-ui:
    image: ghcr.io/huggingface/chat-ui:latest
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - MONGODB_URL=mongodb://mongo:27017
      - OPENAI_BASE_URL=http://your-inference-host:8000/v1
      - OPENAI_API_KEY=local-secret-key
    depends_on:
      - mongo

volumes:
  mongo_data:

Once running via docker compose up -d, Chat UI queries http://your-inference-host:8000/v1/models, fetches the list of active models hosted by your engine, and displays them directly in the chat interface at http://localhost:3000.


Advanced Model Tailoring via MODELS

While automatic discovery works out of the box, production enterprise setups usually require exact parameter clamping, system prompt overrides, or custom model branding. Chat UI supports explicit declaration via a JSON array in .env.local or environment variables:

MODELS=`[
  {
    "id": "Qwen/Qwen2.5-14B-Instruct",
    "name": "Corporate-Internal-Qwen-14B",
    "description": "On-premises self-hosted model running on internal vLLM cluster.",
    "parameters": {
      "temperature": 0.3,
      "max_new_tokens": 4096,
      "top_p": 0.9
    },
    "endpoints": [
      {
        "type": "openai",
        "baseURL": "http://your-inference-host:8000/v1"
      }
    ]
  }
]`

If your internal endpoint uses custom internal CA certificates, pass NODE_EXTRA_CA_CERTS=/path/to/internal-ca.crt or set REJECT_UNAUTHORIZED=false in local staging to prevent SvelteKit backend fetch failures.


Crucial Air-Gap and Enterprise Gotchas

When cutting HuggingChat loose from the Hugging Face cloud, three operational realities demand attention:

  1. Web Search Dependencies: Public HuggingChat includes an integrated web search toggle powered by third-party search APIs (like Serper or Google). In an isolated intranet, that feature will fail unless you configure SERPAPI_KEY with outbound internet egress, or redirect Chat UI to an internally hosted SearXNG meta-search instance.
  2. Authentication and Enterprise SSO: Out of the box, Chat UI uses local cookie sessions. In corporate environments, you should configure its native OpenID Connect (OIDC) parameters (OPENID_CLIENT_ID, OPENID_CLIENT_SECRET, OPENID_ISSUER_URL) to bind login to Okta, Keycloak, or Microsoft Entra ID.
  3. No Hugging Face Hub Call Home: Ensure you do not pass a HF_TOKEN unless you intentionally want Chat UI to pull model metadata or community assistants from Hugging Face Hub. Leaving it unconfigured guarantees that prompt payloads and chat logs remain confined to your MongoDB instance and inference host.

365Finds Technical Verdict: Should You Pick Chat UI?

At 365Finds, we appreciate Chat UI for its clean typography, polished multi-turn streaming, and zero-clutter conversational layout. If your engineering objective is to replicate the responsive, approachable user experience of HuggingChat for an internal team—without users feeling like they are operating a developer console—self-hosting Chat UI on top of vLLM is an outstanding choice.

However, 365Finds advises engineering leaders to recognize Chat UI's boundaries. Compared to mature enterprise UI alternatives like Open WebUI or LibreChat:

If your primary requirement is a secure, elegant, distraction-free chat portal for internal open-source models, Hugging Face Chat UI delivers that signature HuggingChat experience entirely outside the cloud. If you need enterprise multi-tenancy, per-user billing limits, and deep knowledge-base management, you will outgrow it quickly and should consider Open WebUI instead.

References