HuggingFaceProvider
Namespace: Vercel.AI.HuggingFace
public sealed class HuggingFaceProvider : OpenAICompatibleProviderHuggingFace provider. OpenAI Chat Completions compatible at https://router.huggingface.co/v1.
Inheritance: object → ProviderBase → OpenAICompatibleProvider
Constructors
Section titled “Constructors”HuggingFaceProvider(HttpClient, OpenAICompatibleOptions?)
Section titled “HuggingFaceProvider(HttpClient, OpenAICompatibleOptions?)”public HuggingFaceProvider(HttpClient httpClient, OpenAICompatibleOptions? options = null)Creates a provider.
Parameters
| Name | Type | Description |
|---|---|---|
httpClient |
HttpClient | |
options |
OpenAICompatibleOptions |
Fields
Section titled “Fields”ApiKeyVariable
Section titled “ApiKeyVariable”public const string ApiKeyVariable = "HUGGINGFACE_API_KEY"Environment variable for the API key.
Value: string
DefaultBaseUrl
Section titled “DefaultBaseUrl”public const string DefaultBaseUrl = "https://router.huggingface.co/v1"Default API origin.
Value: string
ProviderId
Section titled “ProviderId”public const string ProviderId = "huggingface"Provider id.
Value: string
Methods
Section titled “Methods”Create(OpenAICompatibleOptions?, HttpMessageHandler?)
Section titled “Create(OpenAICompatibleOptions?, HttpMessageHandler?)”public static HuggingFaceProvider Create(OpenAICompatibleOptions? options = null, HttpMessageHandler? handler = null)Creates a provider. Pass a handler from tests.
Parameters
| Name | Type | Description |
|---|---|---|
options |
OpenAICompatibleOptions | |
handler |
HttpMessageHandler |
Returns: HuggingFaceProvider
EmbeddingModel(string)
Section titled “EmbeddingModel(string)”public override IEmbeddingModel EmbeddingModel(string modelId)Returns an embedding model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IEmbeddingModel
ImageModel(string)
Section titled “ImageModel(string)”public override IImageModel ImageModel(string modelId)Returns an image model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IImageModel
ResponsesModel(string)
Section titled “ResponsesModel(string)”public HuggingFaceResponsesLanguageModel ResponsesModel(string modelId)Creates a Responses API model. LanguageModel(string) stays on Chat Completions.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: HuggingFaceResponsesLanguageModel
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product