AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Run Local or Private Models in HuggingChat with Custom Endpoints

Annika Bernklau · 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

If you want the clean, reactive interface of HuggingChat while keeping your proprietary data strictly inside your local machine or private cloud, there is an immediate hurdle to clear. The public web app at huggingface.co/chat runs on Hugging Face’s hosted infrastructure. Pointing a cloud-hosted public web client at an unexposed internal endpoint like http://localhost:11434 fails on basic network boundaries and defeats the very purpose of data isolation.

The genuine, production-grade way to run local or private open-source models inside HuggingChat is to deploy its open-source foundation: Chat UI (huggingface/chat-ui).

Chat UI is the exact codebase powering HuggingChat. Hugging Face built it on SvelteKit and designed it to plug into OpenAI-compatible custom endpoints. At 365Finds, we appreciate this architectural transparency. Instead of forcing you into a proprietary ecosystem, Hugging Face gives you the identical user interface—message branches, web search integrations, prompt management, and tool handling—while letting you direct the inference traffic wherever your privacy policy requires.

Here is how to set up local and private models inside the HuggingChat interface using custom endpoints, along with the networking nuances that frequently trip teams up.


Step 1: Prepare Your Custom Model Backend

Chat UI communicates with backends through the standard OpenAI-compatible /v1 chat completions protocol. You can run your model locally or host it on private cloud infrastructure.

Option A: Local Ollama (Mac, Linux, Windows)

Ollama exposes an OpenAI-compatible bridge out of the box at port 11434.

  1. Pull and test your chosen model:
    ollama run llama3.3:8b
    
  2. By default, Ollama listens on 127.0.0.1:11434. If you plan to run Chat UI inside a Docker container, Ollama must accept connections from external bridge interfaces. Set the environment variable:
    export OLLAMA_HOST=0.0.0.0:11434
    export OLLAMA_ORIGINS="*"
    ollama serve
    

Option B: High-Throughput vLLM or llama.cpp Server

If you serve open weights (such as Qwen 2.5, DeepSeek, or Mistral) on dedicated hardware:

Option C: Hugging Face Dedicated Inference Endpoints (VPC Privacy)

For corporate setups where on-premise GPUs are unavailable, deploy a private Dedicated Endpoint directly in Hugging Face Hub under your cloud VPC (AWS, Azure, or GCP). Choose Protected or Private routing. The endpoint URL will format as: https://<endpoint-id>.<region>.endpoints.huggingface.cloud/v1


Step 2: Deploy Chat UI (The HuggingChat Frontend)

365Finds recommends two primary deployment methods: Docker for fast, contained evaluation, or Node.js for deep template hacking.

Method 1: Instant Docker Setup (Recommended)

Hugging Face maintains an all-in-one container image ghcr.io/huggingface/chat-ui-db that packages Chat UI with an embedded MongoDB database, eliminating multi-container orchestration for desktop users.

Create an environment file named .env.local:

# Point to your local Ollama or custom server
OPENAI_BASE_URL=http://host.docker.internal:11434/v1
OPENAI_API_KEY=ollama

# Application port and public URL
PORT=3000
PUBLIC_APP_NAME="365Finds Private HuggingChat"

Run the container:

docker run -d \
  -p 3000:3000 \
  --add-host=host.docker.internal:host-gateway \
  --env-file .env.local \
  -v chat-ui-data:/data \
  --name huggingchat-local \
  ghcr.io/huggingface/chat-ui-db:latest

Network Note: The flag --add-host=host.docker.internal:host-gateway ensures that the Docker container on Linux can reach Ollama or vLLM running directly on your host machine. On Docker Desktop for macOS and Windows, host.docker.internal resolves automatically.

Method 2: Native Node.js Run

If you prefer running Chat UI directly on your host system:

  1. Clone the repository:
    git clone https://github.com/huggingface/chat-ui.git
    cd chat-ui
    
  2. Install dependencies:
    npm install
    
  3. Configure .env.local:
    OPENAI_BASE_URL=http://127.0.0.1:11434/v1
    OPENAI_API_KEY=ollama
    
    Note: If MONGODB_URL is omitted in recent builds, Chat UI defaults to an embedded local database in ./db.
  4. Start the development server:
    npm run dev -- --open
    

Navigate to http://localhost:5173. Chat UI queries the ${OPENAI_BASE_URL}/models endpoint on launch and displays all models loaded in your local runner.


Step 3: Configure Multiple Models and Custom Parameters

Relying solely on automatic /models discovery assigns generic default parameters. To give your models clear labels, define custom system prompts, or tune context lengths, configure the MODELS environment variable inside .env.local using JSON format:

MODELS=`[
  {
    "id": "llama3.3:8b",
    "name": "Llama 3.3 8B (Local)",
    "description": "Running strictly locally via Ollama without external telemetry.",
    "parameters": {
      "temperature": 0.2,
      "max_new_tokens": 4096
    },
    "endpoints": [{
      "type": "openai",
      "baseURL": "http://127.0.0.1:11434/v1"
    }]
  },
  {
    "id": "deepseek-coder",
    "name": "DeepSeek Coder (Private VPC)",
    "description": "Dedicated Inference Endpoint deployed on Hugging Face Cloud.",
    "parameters": {
      "temperature": 0.1,
      "max_new_tokens": 8192
    },
    "endpoints": [{
      "type": "openai",
      "baseURL": "https://your-custom-endpoint.endpoints.huggingface.cloud/v1",
      "authorization": "Bearer hf_your_api_token"
    }]
  }
]`

Restart the service. Your dropdown inside HuggingChat will now display both the private local instance and your dedicated cloud endpoint with customized context handling.


Step 4: Verification and Common Pitfalls

Before entering sensitive data, confirm the setup:

  1. Verify Network Isolation: Open your browser's Developer Tools (Network tab) on http://localhost:3000. Submit a prompt. All streaming requests should target your local port or your specified private endpoint. No prompt tokens should ping huggingface.co.
  2. Handle CORS Errors: If Chat UI fails to retrieve responses from Ollama, verify that Ollama was launched with OLLAMA_ORIGINS="*". Without this, Ollama rejects requests originating from web frontends running on different ports.
  3. Context Length Truncation: Local backends default to conservative context windows (Ollama frequently defaults to 2048 tokens). Ensure you configure num_ctx in your Ollama Modelfile or set max_new_tokens in your Chat UI MODELS definition to avoid truncated reasoning chains.

365Finds Take: Why This Setup Beats Cloud SaaS

At 365Finds, we look at interface frameworks pragmatically. Heavy enterprise web wrappers often bundle unwanted telemetry, bloated permission structures, or complex database requirements. Hugging Face’s Chat UI provides a lean, fast SvelteKit application that matches the polished aesthetic of commercial chat assistants while remaining completely subservient to your infrastructure.

If absolute data privacy is your priority, do not look for hidden toggle buttons on the public huggingface.co/chat site. Deploy Chat UI via Docker on your workstation or internal cluster, wire OPENAI_BASE_URL to your local Ollama or vLLM instance, and you own the entire inference stack from UI pixel to GPU silicon.

References