Model providers

Using Hugging Face with OpenClaw

4 min read

Browse more in Model providers.

All model providers guides →

This guide shows you how to connect OpenClaw to Hugging Face Inference Providers using their OpenAI-compatible router API. You will create a fine-grained Hugging Face token, onboard it into OpenClaw, and set Hugging Face models like DeepSeek, Qwen, and Llama as your agent defaults and fallbacks.

co/v1` with model aliases and policy suffixes wired up.

Setup flow

Prerequisites

  • A Hugging Face account with access to Inference Providers and permission to create fine-grained tokens.
  • A fine-grained Hugging Face token with the 'Make calls to Inference Providers' permission enabled.
  • An existing OpenClaw installation where you can run the `openclaw` CLI and edit its config files.
  • Network access from your OpenClaw environment to `https://router.huggingface.co/v1`.

Steps

  1. 1

    Create a fine-grained Hugging Face token

    Start by creating the token that OpenClaw will use to talk to Hugging Face Inference Providers. If you skip the specific permission, the router will reject every request and model discovery will fail.

    Go to the Hugging Face token creation page and ensure the token has the 'Make calls to Inference Providers' permission enabled.

  2. 2

    Run interactive onboarding for the Hugging Face provider

    Use the OpenClaw onboarding flow to register Hugging Face as a model provider and store your token. Pick Hugging Face in the provider dropdown when prompted, then run this command so OpenClaw knows to ask for a Hugging Face API key.

    If the token is invalid or missing permissions, the subsequent model dropdown will not populate correctly.

    bash
    openclaw onboard --auth-choice huggingface-api-key
  3. 3

    Select a default Hugging Face model for your agents

    After onboarding, choose which Hugging Face model OpenClaw should use by default for chat completions. In the Default Hugging Face model dropdown, OpenClaw loads the list from the Inference API when your token works; otherwise it falls back to a built-in catalog.

    You can also hard-code or change the default later in your config using the snippet below.

    json
    {
      agents: {
        defaults: {
          model: { primary: "huggingface/deepseek-ai/DeepSeek-R1" },
        },
      },
    }
  4. 4

    Verify Hugging Face models are available in OpenClaw

    Once the token and default model are set, confirm that OpenClaw can see Hugging Face models. This command queries the Hugging Face router (and merges results with the built-in catalog) so you can verify IDs and availability.

    If the list is empty or missing models you expect, your token or network access is likely misconfigured.

    bash
    openclaw models list --provider huggingface
  5. 5

    Automate setup with non-interactive onboarding

    For CI or scripted environments, configure Hugging Face without the interactive prompts. This command wires your `HF_TOKEN` into OpenClaw, sets the mode to local, and configures Hugging Face as the auth choice.

    It also sets `huggingface/deepseek-ai/DeepSeek-R1` as the default model so your agents are ready to call the router immediately.

    bash
    openclaw onboard --non-interactive \
      --mode local \
      --auth-choice huggingface-api-key \
      --huggingface-api-key "$HF_TOKEN"
  6. 6

    Configure model fallbacks and aliases for Hugging Face models

    Once the basics work, define primary models, fallbacks, and human-friendly aliases so your agents can fail over cleanly across Hugging Face models. json`) and control how models appear in the CLI and UI.

    Use them to wire DeepSeek, Qwen, Llama, and GPT-OSS variants with clear labels and policy suffixes.

    json
    {
      agents: {
        defaults: {
          model: {
            primary: "huggingface/deepseek-ai/DeepSeek-R1",
            fallbacks: ["huggingface/Qwen/Qwen3-8B"],
          },
          models: {
            "huggingface/deepseek-ai/DeepSeek-R1": { alias: "DeepSeek R1" },
            "huggingface/Qwen/Qwen3-8B": { alias: "Qwen3 8B" },
          },
        },
      },
    }
    
    {
      agents: {
        defaults: {
          model: { primary: "huggingface/Qwen/Qwen3-8B" },
          models: {
            "huggingface/Qwen/Qwen3-8B": { alias: "Qwen3 8B" },
            "huggingface/Qwen/Qwen3-8B:cheapest": { alias: "Qwen3 8B (cheapest)" },
            "huggingface/Qwen/Qwen3-8B:fastest": { alias: "Qwen3 8B (fastest)" },
          },
        },
      },
    }
    
    {
      agents: {
        defaults: {
          model: {
            primary: "huggingface/deepseek-ai/DeepSeek-V3.2",
            fallbacks: [
              "huggingface/meta-llama/Llama-3.3-70B-Instruct",
              "huggingface/openai/gpt-oss-120b",
            ],
          },
          models: {
            "huggingface/deepseek-ai/DeepSeek-V3.2": { alias: "DeepSeek V3.2" },
            "huggingface/meta-llama/Llama-3.3-70B-Instruct": { alias: "Llama 3.3 70B" },
            "huggingface/openai/gpt-oss-120b": { alias: "GPT-OSS 120B" },
          },
        },
      },
    }
    
    {
      agents: {
        defaults: {
          model: { primary: "huggingface/Qwen/Qwen2.5-7B-Instruct:cheapest" },
          models: {
            "huggingface/Qwen/Qwen2.5-7B-Instruct": { alias: "Qwen2.5 7B" },
            "huggingface/Qwen/Qwen2.5-7B-Instruct:cheapest": { alias: "Qwen2.5 7B (cheap)" },
            "huggingface/deepseek-ai/DeepSeek-R1:fastest": { alias: "DeepSeek R1 (fast)" },
            "huggingface/meta-llama/Llama-3.1-8B-Instruct": { alias: "Llama 3.1 8B" },
          },
        },
      },
    }

Configuration

OptionDescriptionExample
HUGGINGFACE_HUB_TOKENFine-grained Hugging Face token that OpenClaw uses to call the Hugging Face Inference Providers router and discover models.hf_xxx_make_calls_to_inference_providers
HF_TOKENAlias environment variable for the Hugging Face token; OpenClaw accepts this as an alternative to HUGGINGFACE_HUB_TOKEN.hf_yyy_make_calls_to_inference_providers
agents.defaults.model.primarySets the primary default model for your agents, using the Hugging Face model ref format prefixed with 'huggingface/'.huggingface/deepseek-ai/DeepSeek-R1
agents.defaults.model.fallbacksConfigures an ordered list of fallback Hugging Face models that OpenClaw uses when the primary model fails.["huggingface/Qwen/Qwen3-8B"]
agents.defaults.models."huggingface/deepseek-ai/DeepSeek-R1".aliasOverrides the display name for the DeepSeek R1 model in the CLI and UI.DeepSeek R1
agents.defaults.models."huggingface/Qwen/Qwen3-8B:cheapest".aliasSets a custom label for the Qwen3 8B cheapest policy variant so you can distinguish it from fastest or default.Qwen3 8B (cheapest)

Troubleshooting

Hugging Face model dropdown only shows a small built-in list instead of your full catalog.

co/v1/models` to discover models; without a working token it falls back to a built-in catalog. Ensure `HUGGINGFACE_HUB_TOKEN` or `HF_TOKEN` is set with the 'Make calls to Inference Providers' permission and restart any Gateway daemon so it inherits the env vars.

bash
GET https://router.huggingface.co/v1/models

API requests to Hugging Face are rejected after onboarding.

The docs state that the token must have the 'Make calls to Inference Providers' permission enabled or API requests will be rejected. shellEnv`).

Gateway works in a shell but fails to use Hugging Face models when running as a daemon.

When the Gateway runs under launchd or systemd it may not see your shell env vars, so OpenClaw starts without `HUGGINGFACE_HUB_TOKEN` or `HF_TOKEN` and only uses the built-in catalog. shellEnv` so the daemon process has access to it, then restart the service.

Frequently asked questions

Powered by Mem0

Add persistent memory to OpenClaw

Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.

More in Model providers