Table of Contents

Class HuggingFaceDetector

Namespace
JD.AI.Core.Providers
Assembly
JD.AI.Core.dll

Detects HuggingFace Inference API availability via API key. Dynamically discovers the most popular inference-ready chat models from the HuggingFace Hub, falling back to a curated catalog when offline.

HuggingFace deprecated the old api-inference.huggingface.co endpoint (returns 410 Gone). All requests now use the OpenAI-compatible router: https://router.huggingface.co/v1/

public sealed class HuggingFaceDetector : ApiKeyProviderDetectorBase, IProviderDetector
Inheritance
HuggingFaceDetector
Implements
Inherited Members

Constructors

HuggingFaceDetector(ProviderConfigurationManager)

public HuggingFaceDetector(ProviderConfigurationManager config)

Parameters

config ProviderConfigurationManager

Properties

KnownModels

Static fallback catalog used when DiscoverModelsAsync(string, CancellationToken) is not overridden or when live discovery fails.

protected override IReadOnlyList<ProviderModelInfo> KnownModels { get; }

Property Value

IReadOnlyList<ProviderModelInfo>

Methods

ConfigureKernel(IKernelBuilder, ProviderModelInfo, string)

Uses the OpenAI-compatible HuggingFace router endpoint instead of the deprecated api-inference.huggingface.co endpoint (which returns 410 Gone as of 2025). New endpoint: https://router.huggingface.co/v1/

protected override void ConfigureKernel(IKernelBuilder builder, ProviderModelInfo model, string apiKey)

Parameters

builder IKernelBuilder
model ProviderModelInfo
apiKey string

DiscoverModelsAsync(string, CancellationToken)

Override to query the provider's API for its current model list. The default implementation returns KnownModels. Implementations should catch transport errors and return KnownModels as the fallback.

protected override Task<IReadOnlyList<ProviderModelInfo>> DiscoverModelsAsync(string apiKey, CancellationToken ct)

Parameters

apiKey string
ct CancellationToken

Returns

Task<IReadOnlyList<ProviderModelInfo>>