Skip to content

Add Hugging Face Inference provider - #215

Merged
sroussey merged 6 commits into
mainfrom
copilot/add-ai-providers
Feb 18, 2026
Merged

Add Hugging Face Inference provider#215
sroussey merged 6 commits into
mainfrom
copilot/add-ai-providers

Conversation

Copilot AI commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Adds the Hugging Face Inference API provider following the existing OpenAI architecture pattern.

Provider

HF Inference (provider-hf-inference/)

  • Uses @huggingface/inference SDK (InferenceClient)
  • Supports: TextGeneration, TextEmbedding, TextRewriter, TextSummary
  • Optional provider field routes to specific HF inference backends (fal-ai, fireworks-ai)
  • API key: provider_config.api_key or HF_TOKEN env var

Structure

The provider follows the 6-file pattern:

provider-hf-inference/
├── common/
│   ├── HFI_Constants.ts
│   ├── HFI_ModelSchema.ts
│   └── HFI_JobRunFns.ts
├── HfInferenceProvider.ts
├── HFI_Worker.ts
└── index.ts

Integration

  • Added exports to src/index.ts (constants, schemas, provider classes)
  • Added ./hf-inference to package.json exports
  • Added @huggingface/inference as optional peer dependency
  • Updated build scripts for new entry point

Usage

import { HF_INFERENCE, HfInferenceProvider } from "@workglow/ai-provider";
import { HFI_TASKS } from "@workglow/ai-provider/hf-inference";

const model = {
  provider: "HF_INFERENCE",
  provider_config: {
    model_name: "meta-llama/Llama-3.3-70B-Instruct",
    provider: "fireworks-ai" // optional routing
  }
};

await new HfInferenceProvider(HFI_TASKS).register({ mode: "inline" });
Original prompt

This section details on the original issue you should resolve

<issue_title>Add HF and featherless inference</issue_title>
<issue_description>---
name: Add AI Providers
overview: Create two new AI providers (Hugging Face Inference API and Featherless.ai) following the established OpenAI provider pattern, each with constants, model schema, task implementations, provider class, worker, and barrel exports.
todos:

  • id: hf-inference-provider
    content: "Create the Hugging Face Inference provider (6 files: constants, model schema, job run fns, provider class, worker, index)"
    status: pending
  • id: featherless-provider
    content: "Create the Featherless.ai provider (6 files: constants, model schema, job run fns, provider class, worker, index)"
    status: pending
  • id: integrate-exports
    content: Update src/index.ts barrel exports and package.json (exports, dependencies, build scripts)
    status: pending
    isProject: false

Add Hugging Face Inference and Featherless.ai Providers

Both providers will follow the exact same architecture as the existing OpenAI provider in libs/packages/ai-provider/src/provider-openai/, with each consisting of 6 files organized into a directory with a common/ subdirectory.

Architecture (per provider)

Each provider directory contains:

  • common/<PREFIX>_Constants.ts - Provider name constant
  • common/<PREFIX>_ModelSchema.ts - Model config schema (provider discriminator, provider_config shape)
  • common/<PREFIX>_JobRunFns.ts - Task run/stream functions + task registries
  • <Name>Provider.ts - Provider class extending AiProvider
  • <Name>_Worker.ts - Worker registration function
  • index.ts - Barrel exports

Both providers support the same 4 task types as OpenAI: TextGenerationTask, TextEmbeddingTask, TextRewriterTask, TextSummaryTask.


Provider 1: Hugging Face Inference (provider-hf-inference/)

SDK: @huggingface/inference (uses InferenceClient)

  • Constant: HF_INFERENCE = "HF_INFERENCE"
  • Model config: { provider: "HF_INFERENCE", provider_config: { model_name, api_key?, provider? } }
    • provider is an optional field to route to specific HF inference providers (e.g. "fal-ai", "fireworks-ai")
  • Task implementations use lazy import("@huggingface/inference") and call:
    • client.chatCompletion(...) for text generation, rewriting, summarization
    • client.featureExtraction(...) for embeddings
  • Streaming uses client.chatCompletionStream(...) yielding text-delta events

Key file: common/HFI_JobRunFns.ts -- pattern mirrors provider-openai/common/OpenAI_JobRunFns.ts but swaps the OpenAI SDK calls for HF Inference SDK calls.


Provider 2: Featherless.ai (provider-featherless/)

SDK: openai (Featherless is OpenAI-compatible, base URL: https://api.featherless.ai/v1)

  • Constant: FEATHERLESS_AI = "FEATHERLESS_AI"
  • Model config: { provider: "FEATHERLESS_AI", provider_config: { model_name, api_key? } }
  • Task implementations are nearly identical to OpenAI but:
    • Use FEATHERLESS_API_KEY env var fallback
    • Default baseURL to https://api.featherless.ai/v1
    • No organization field
    • No embedding support (Featherless doesn't support /v1/embeddings), so TextEmbeddingTask will be excluded

Key file: common/Featherless_JobRunFns.ts -- closely mirrors provider-openai/common/OpenAI_JobRunFns.ts with adjusted base URL and API key env var.


Integration Changes

libs/packages/ai-provider/src/index.ts

Add 6 new export lines (constants, model schemas, provider classes) for both providers.

libs/packages/ai-provider/package.json

  • Add exports entries: "./hf-inference" and "./featherless"
  • Add @huggingface/inference to peerDependencies (optional), peerDependenciesMeta, and devDependencies
  • openai is already a peer dependency (reused by Featherless)
  • Update build-code and watch-code scripts to include the two new entry points

File Inventory (14 new files)

Hugging Face Inference (7 files):

  • src/provider-hf-inference/common/HFI_Constants.ts
  • src/provider-hf-inference/common/HFI_ModelSchema.ts
  • src/provider-hf-inference/common/HFI_JobRunFns.ts
  • src/provider-hf-inference/HfInferenceProvider.ts
  • src/provider-hf-inference/HFI_Worker.ts
  • src/provider-hf-inference/index.ts

Featherless.ai (7 files):

  • src/provider-featherless/common/Featherless_Constants.ts
  • src/provider-featherless/common/Featherless_ModelSchema.ts
  • src/provider-featherless/common/Featherless_JobRunFns.ts
  • src/provider-featherless/FeatherlessProvider.ts
  • src/provider-featherless/Featherless_Worker.ts
  • `src/provider-feather...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add Hugging Face and Featherless AI providers Add Hugging Face Inference and Featherless.ai providers Feb 18, 2026
Copilot AI requested a review from sroussey February 18, 2026 17:11
sroussey and others added 4 commits February 18, 2026 18:49
- Removed unnecessary registry-url entries from the release workflow for both Node and Bun setups.
- Modified job queue tests to improve assertions on pending job counts, ensuring at least 12 jobs remain pending after submissions, without asserting specific job statuses.
Co-authored-by: sroussey <127349+sroussey@users.noreply.github.com>
Co-authored-by: sroussey <127349+sroussey@users.noreply.github.com>
@sroussey
sroussey force-pushed the copilot/add-ai-providers branch from b64b994 to 9037529 Compare February 18, 2026 18:57
@sroussey
sroussey marked this pull request as ready for review February 18, 2026 18:58
@sroussey

Copy link
Copy Markdown
Collaborator

@copilot remove the featherless related code

Co-authored-by: sroussey <127349+sroussey@users.noreply.github.com>

Copilot AI commented Feb 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot remove the featherless related code

Removed all Featherless-related code. The PR now only includes the HF Inference provider. Changes in commit 8d6a062.

Copilot AI changed the title Add Hugging Face Inference and Featherless.ai providers Add Hugging Face Inference provider Feb 18, 2026
@sroussey
sroussey merged commit 541af10 into main Feb 18, 2026
1 check passed
@sroussey
sroussey deleted the copilot/add-ai-providers branch February 25, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HF and featherless inference

2 participants