Soenneker.OpenAI.Moderation.HttpClients
11.0.98
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.OpenAI.Moderation.HttpClients --version 11.0.98
NuGet\Install-Package Soenneker.OpenAI.Moderation.HttpClients -Version 11.0.98
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" Version="11.0.98" />
<PackageVersion Include="Soenneker.OpenAI.Moderation.HttpClients" Version="11.0.98" />
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" />
paket add Soenneker.OpenAI.Moderation.HttpClients --version 11.0.98
#r "nuget: Soenneker.OpenAI.Moderation.HttpClients, 11.0.98"
#:package Soenneker.OpenAI.Moderation.HttpClients@11.0.98
#addin nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=11.0.98
#tool nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=11.0.98
Soenneker.OpenAI.Moderation.HttpClients
Provides a cached HttpClient configured for OpenAI moderation requests.
Install
dotnet add package Soenneker.OpenAI.Moderation.HttpClients
Registration
using Microsoft.Extensions.DependencyInjection;
using Soenneker.OpenAI.Moderation.HttpClients.Registrars;
services.AddOpenAIModerationHttpClientAsSingleton();
Use AddOpenAIModerationHttpClientAsScoped() when the wrapper must follow a consumer scope. Both registrations reuse the singleton HTTP-client cache; disposing a scoped wrapper does not destroy the shared client.
Configuration
The API key is required:
{
"OpenAI": {
"Moderation": {
"ApiKey": "..."
}
}
}
Keep the key in a secret store or environment variable. The client uses https://api.openai.com/v1 and an Authorization: Bearer <token> header by default. Compatible endpoints can be configured with these optional keys:
{
"OpenAI": {
"ClientBaseUrl": "https://example.com/v1",
"AuthHeaderName": "Authorization",
"AuthHeaderValueTemplate": "Bearer {token}"
}
}
{token} is replaced with OpenAI:Moderation:ApiKey.
Usage
Inject IOpenAIModerationHttpClient and retrieve the cached client:
using Soenneker.OpenAI.Moderation.HttpClients.Abstract;
HttpClient client = await moderationHttpClient.Get(cancellationToken);
using var request = new HttpRequestMessage(HttpMethod.Get, "models");
using HttpResponseMessage response = await client.SendAsync(request, cancellationToken);
response.EnsureSuccessStatusCode();
Do not dispose the returned HttpClient; its lifetime is owned by the singleton cache.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Configuration (>= 11.0.914)
- Soenneker.Utils.HttpClientCache (>= 11.0.2141)
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 |
|---|---|---|
| 11.0.114 | 51 | 11/19/2026 |
| 11.0.112 | 51 | 11/18/2026 |
| 11.0.109 | 50 | 11/18/2026 |
| 11.0.108 | 90 | 11/15/2026 |
| 11.0.107 | 92 | 11/15/2026 |
| 11.0.105 | 117 | 11/11/2026 |
| 11.0.104 | 99 | 11/11/2026 |
| 11.0.103 | 87 | 11/11/2026 |
| 11.0.102 | 93 | 11/11/2026 |
| 11.0.101 | 93 | 11/11/2026 |
| 11.0.100 | 116 | 11/3/2026 |
| 11.0.99 | 100 | 11/3/2026 |
| 11.0.98 | 97 | 11/3/2026 |
| 11.0.97 | 90 | 11/3/2026 |
| 11.0.96 | 115 | 10/27/2026 |
| 11.0.95 | 105 | 10/27/2026 |
| 11.0.93 | 106 | 10/26/2026 |
| 11.0.92 | 86 | 10/26/2026 |
| 11.0.90 | 88 | 10/26/2026 |
| 11.0.89 | 96 | 10/26/2026 |
Updated Multiple NuGet packages