WebInfer

🤗

Hugging Face

Inference API and serverless endpoints

Budget
Specialized
API

Configure Hugging Face

Add your Hugging Face API key in Settings

Go to Settings
Capabilities
chat
embeddings
open-source
Configuration Schema
Required and optional fields for configuring this provider
FieldTypeRequired
apiKey
password
Required
CLI Usage
For users running the daemon server locally or a self-hosted gateway

Add provider:

npx webinfer provider add huggingface --key YOUR_API_KEY

Test connection:

npx webinfer provider test huggingface

Get your API key from https://huggingface.co/

Programmatic Usage
Use Hugging Face in your code with WebInfer

Basic usage:

import { generateText } from "webinfer"

// WebInfer automatically routes to the best available provider
const result = await generateText({
  prompt: "Write a haiku about programming"
})

console.log(result.text)

Specify Hugging Face explicitly:

import { generateText } from "webinfer"

const result = await generateText({
  prompt: "Write a haiku about programming",
  provider: "huggingface"
})

console.log(result.text)
console.log("Provider:", result.provider)
console.log("Model:", result.model)

Streaming:

import { streamText } from "webinfer"

const { textStream } = await streamText({
  prompt: "Write a story about AI",
  provider: "huggingface"
})

for await (const chunk of textStream) {
  process.stdout.write(chunk)
}