HuggingFace.Net
1.0.0
dotnet add package HuggingFace.Net --version 1.0.0
NuGet\Install-Package HuggingFace.Net -Version 1.0.0
<PackageReference Include="HuggingFace.Net" Version="1.0.0" />
<PackageVersion Include="HuggingFace.Net" Version="1.0.0" />
<PackageReference Include="HuggingFace.Net" />
paket add HuggingFace.Net --version 1.0.0
#r "nuget: HuggingFace.Net, 1.0.0"
#:package HuggingFace.Net@1.0.0
#addin nuget:?package=HuggingFace.Net&version=1.0.0
#tool nuget:?package=HuggingFace.Net&version=1.0.0
HuggingFace.Net
HuggingFace.Net is a .NET client library for interacting with HuggingFace's Inference Endpoints API. It provides a robust and easy-to-use interface for managing and calling HuggingFace machine learning models.
Features
- 🔐 Secure API Authentication
- 🚀 Inference Endpoint Management
- Create, delete, and manage endpoints
- Scale endpoints up/down
- Monitor endpoint status
- 🤖 Model Inference
- Call models with typed responses
- Raw response handling
- Automatic retries with exponential backoff
- ⚡ Performance
- Connection pooling
- Configurable timeouts
- Rate limit handling
- 🛡️ Error Handling
- Custom exceptions for different error scenarios
- Detailed error messages
- HTTP status code handling
Installation
You can install the package via NuGet:
dotnet add package HuggingFace.Net
Usage
Here's a quick example of how to use the library:
// Create client with API key
var client = HuggingFaceClientFactory.Create("your-api-key-here", "namespace");
try
{
// Test connection
var connected = await client.ConnectAsync();
Console.WriteLine($"Connected: {connected}");
// Check endpoint status
var status = await client.GetEndpointStatusAsync("model-name");
Console.WriteLine($"Endpoint Status: {status.Status}, Available: {status.IsAvailable}");
// Call model for text generation
var input = new Models.TextGenerationInput
{
Inputs = "Hello, how are you?",
Parameters = new Models.TextGenerationParameters
{
MaxNewTokens = 50,
Temperature = 0.7
}
};
var response = await client.CallModelAsync<Models.TextGenerationResponse[]>(
"model-name", input);
}
catch (HuggingFaceException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
Configuration
You can configure the client with custom options:
var options = new HuggingFaceClientOptions
{
ApiKey = "your-api-key",
Namespace = "your-namespace",
BaseUrl = "https://api.endpoints.huggingface.cloud/v2",
Timeout = TimeSpan.FromSeconds(30),
MaxRetries = 3,
RetryDelay = TimeSpan.FromSeconds(1),
UseExponentialBackoff = true
};
var client = HuggingFaceClientFactory.Create(options);
Error Handling
The library includes custom exceptions for different error scenarios:
HuggingFaceException: Base exception for all library errorsHuggingFaceAuthenticationException: Authentication errorsHuggingFaceRateLimitException: Rate limit exceeded errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 2,803 | 6/23/2025 |
| 1.0.0-beta.2 | 147 | 6/30/2025 |
| 1.0.0-beta.1 | 153 | 6/24/2025 |