AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Privacy, Conversation History, and Hugging Face API Tokens in HuggingChat

365Finds Editorial
Indexed 11,430 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

For privacy-conscious users and developers, HuggingChat stands out from proprietary AI chat platforms by providing transparent data boundaries, open-source auditability, and granular infrastructure control. Built on the open-source chat-ui engine, HuggingChat (hosted at huggingface.co/chat) does not sell conversational data or share user interactions with upstream model creators for model training by default.

Whether you are evaluating HuggingChat for daily confidential research or deploying a private interface for your team, configuring data sharing, retention windows, and Hugging Face API tokens ensures your prompts remain protected while unlocking restricted and gated open-weights models.


1. Data Sharing and Privacy Architecture

Understanding how HuggingChat treats conversational inputs requires distinguishing between the public web interface and self-hosted instances.

The Default Privacy Baseline

Hugging Face maintains a "privacy-by-design" stance for HuggingChat:

Data Sharing Controls

In self-hosted deployments and specific experimental builds of chat-ui, administrators can expose an explicit data sharing opt-in toggle via the environment variable PUBLIC_APP_DATA_SHARING=1. When disabled (or set to 0), user conversations are restricted strictly to session delivery and database persistence, preventing any external data donation.

Web Search Privacy Considerations

HuggingChat features an optional Web Search toggle in the prompt bar. When active, HuggingChat extracts search queries from your prompt and forwards them to integrated web search engines (such as Serper or Exa) to fetch grounding context. If your prompt contains sensitive proprietary code, internal hostnames, or confidential business plans, disable Web Search before submitting to prevent sensitive query tokens from reaching external search indexes.

Public Shared Links

HuggingChat allows users to create public snapshots of conversations via the "Share" feature. Generating a share link creates a publicly accessible URL on Hugging Face's domain. Privacy-conscious teams should establish a strict policy never to generate share links for proprietary workflows. If a link is created unintentionally, deleting the underlying conversation removes the public snapshot.


2. Managing Conversation History Retention

HuggingChat gives users precise control over how long their conversational footprint exists, from stateless guest sessions to hard database deletions.

Guest Mode (Zero-Account Session Isolation)

You can use HuggingChat without signing into a Hugging Face account:

Deleting Individual Conversations

When logged into a Hugging Face account, your chat history populates the left-hand navigation sidebar:

  1. Hover over the conversation title in the left panel.
  2. Click the three horizontal dots (...) or the trash icon next to the title.
  3. Confirm deletion.

HuggingChat executes a hard delete on the database record: the conversation document is permanently deleted from MongoDB rather than flagged with a soft-delete status.

Complete Account History Purge

To wipe all historical chat records associated with your account:

  1. Click the Settings gear icon in the lower-left corner of the interface.
  2. Navigate to the Data Controls or conversation management section.
  3. Select Delete all conversations and confirm the prompt.

This action immediately drops all conversation records, associated tool-call outputs, and assistant interactions linked to your Hugging Face user ID.


3. Configuring Hugging Face API Tokens and Gated Models

Connecting API tokens to HuggingChat allows developers to access private Hugging Face Hub repositories, unlock gated model weights, and automate advanced tool calling via the Model Context Protocol (MCP).

Accessing Gated Models in the Web Interface

Leading open-weights models (such as Meta's Llama 3 family) are distributed as "gated models" on the Hugging Face Hub, requiring users to accept license terms before accessing weights or inference endpoints:

  1. Log into your account at Hugging Face.
  2. Visit the official repository page of the gated model (e.g., meta-llama/Meta-Llama-3-70B-Instruct).
  3. Fill out the acknowledgment form and accept the community license terms.
  4. Return to HuggingChat. Because HuggingChat shares your account session, the gated model will now appear as selectable in the model selector dropdown without requiring manual API token injection in the browser.

User Token Forwarding for MCP Servers

HuggingChat supports the Model Context Protocol (MCP), enabling models to execute external tools and query Hub datasets:

  1. Open Settings and select MCP Servers.
  2. Add your custom MCP server endpoint URL.
  3. When configuring MCP integration in enterprise environments, enable MCP_FORWARD_HF_USER_TOKEN=true. This allows the application to forward the authenticated user's Hugging Face token securely to authorized MCP tools, allowing interactions with private corporate spaces and gated datasets without exposing global admin credentials.

Deploying a Self-Hosted Chat UI with HF_TOKEN

For complete control over data sovereignty and network isolation, developers can deploy a private instance of chat-ui using their own Hugging Face User Access Token:

Step 1: Create a Scoped Access Token

  1. Go to Hugging Face Settings > Access Tokens.
  2. Click Create new token.
  3. Select Read permissions (or configure a Fine-grained token with access limited to specific inference repositories). Never use write or administrative tokens for chat frontends.
  4. Copy the token starting with hf_.

Step 2: Configure Environment Variables

In your local or containerized chat-ui project directory, configure .env.local:

# OpenAI-compatible router endpoint for Hugging Face Inference Providers
OPENAI_BASE_URL=https://router.huggingface.co/v1

# Primary auth token for model inference
OPENAI_API_KEY=hf_your_read_token_here

# When set to true with OpenID authentication, each logged-in user's
# personal HF token is passed for inference, isolating rate limits and permissions
USE_USER_TOKEN=true

# Dedicated private MongoDB connection for conversation retention control
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB_NAME=chat-ui-private

# Explicitly disable public data donation
PUBLIC_APP_DATA_SHARING=0

Step 3: Run the Private Instance

Launch your container or Node service:

docker run -d -p 27017:27017 --name mongo-chatui mongo:latest
npm install
npm run dev

4. Privacy and Configuration Matrix

Configuration ScenarioPrivacy LevelData RetentionHugging Face Token RequiredBest Use Case
Guest Web SessionHigh (Anonymous)Session cookies only; dropped on browser closeNoQuick ad-hoc queries, zero account trace
Logged-in Web UIBalancedPersistent in MongoDB; manual per-chat or bulk purgeNo (Inherited via HF account)Daily workflow with history synchronization
Gated Model AccessBalancedPersistent in MongoDB; subject to model license termsAccepted on model repo pageTesting restricted models (e.g., Llama 3)
Self-Hosted chat-uiMaximum (Air-Gapped capable)Self-managed database with custom TTL auto-purgeScoped hf_ Read Token or local server endpointEnterprise IP protection, strict HIPAA/GDPR compliance

5. Recommended Best Practices for Maximum Privacy

  1. Audit Gated Model Licensing: Accepting terms for gated models establishes a legal agreement with the model creator. Review license boundaries before running internal prompts.
  2. Enforce Read-Only Tokens: When setting HF_TOKEN or OPENAI_API_KEY for self-hosted instances, grant only inference read rights to prevent token compromise from exposing account repositories.
  3. Automate Database Expiration: For self-hosted deployments, configure MongoDB TTL indexes on the conversations collection to automatically purge chats after 14 or 30 days.
  4. Disable Web Search for Sensitive Prompts: Prevent unintentional leaks of proprietary code fragments and internal queries to third-party search APIs by keeping web search toggled off during confidential sessions.

References