Skip to main content

HuggingFace

WednesdayAI supports the HuggingFace Inference API (serverless endpoints), giving access to thousands of public and private models hosted on the Hub.

Prerequisites

Create a token at huggingface.co/settings/tokens with at least Read scope. Set it on the gateway host using either accepted variable name:
# Either variable is accepted:
echo 'HUGGINGFACE_HUB_TOKEN=hf_...' >> ~/.openclaw/.env
# or
echo 'HF_TOKEN=hf_...' >> ~/.openclaw/.env
Both HUGGINGFACE_HUB_TOKEN and HF_TOKEN are accepted. If both are set, HUGGINGFACE_HUB_TOKEN takes precedence.

Configuration

{
  models: {
    providers: {
      huggingface: {
        apiKey: "HUGGINGFACE_HUB_TOKEN", // or "HF_TOKEN"
        models: [
          // add model IDs from the HuggingFace Hub
          "meta-llama/Meta-Llama-3.1-8B-Instruct",
          "mistralai/Mistral-7B-Instruct-v0.3",
        ],
      },
    },
  },
}
HuggingFace serverless inference is only available for models that support it. Gated models (e.g. Llama) require you to accept the model’s terms on the Hub before your token can access them.

Selecting a model

{
  agents: {
    defaults: {
      model: { primary: "huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct" },
    },
  },
}
HuggingFace model IDs follow the owner/model-name format used on the Hub.

Troubleshooting

The token is invalid or expired. Generate a new one at huggingface.co/settings/tokens and update ~/.openclaw/.env.
The model requires accepting terms on the HuggingFace Hub before your token can access it. Visit the model page and accept the access agreement.
Not all Hub models support serverless inference. Check the model page for an “Inference API” badge, or deploy the model to a dedicated endpoint.