How to Integrate Hugging Face Models in Openclaw

Image
Table of contents: [Show]

Access thousands of open-source models through Hugging Face's Inference API. This guide walks you through authenticating and configuring Openclaw to use models like DeepSeek-R1.

Quick Start

Hugging Face provides free and paid access to state-of-the-art open models. With Openclaw, you can route requests through their inference endpoints without managing infrastructure.

Get Your API Token

First, create a fine-grained token in your Hugging Face account:

  1. Go to Settings → Tokens
  2. Create a fine-grained token
  3. Enable the Make calls to Inference Providers permission

Save this token as HF_TOKEN or HUGGINGFACE_HUB_TOKEN.

Configuration Options

Option A: Interactive Setup

Run the onboarding wizard:

Openclaw onboard --auth-choice huggingface-api-key

Option B: Non-Interactive Setup

For CI/CD or automated deployments:

Openclaw onboard --non-interactive \ --mode local \ --auth-choice huggingface-api-key \ --huggingface-api-key "$HF_TOKEN"

Using DeepSeek-R1

Once authenticated, configure your default model in ~/.Openclaw/Openclaw.json:

{ "agents": { "defaults": { "model": { "primary": "huggingface/deepseek-ai/DeepSeek-R1" } } } }

Other popular models include meta-llama/Llama-3.3-70B and Qwen/Qwen2.5-72B.

Example Conversation

User: Explain quantum computing in simple terms

Assistant: Quantum computing uses qubits instead of classical bits. While a bit is either 0 or 1, a qubit can exist in a superposition of both states simultaneously. This allows quantum computers to process certain calculations exponentially faster than traditional computers.

Best Practices

  • Use fine-grained tokens with minimal permissions for security
  • Monitor your inference usage in the Hugging Face dashboard
  • For production, consider the Inference Endpoints paid tier for better latency

Hugging Face Integration

Related: Check out our guide on Ollama Models Openclaw for running models locally, or explore vLLM Models Openclaw for high-throughput inference.