Soenneker.OpenAI.Moderation.HttpClients
4.0.68
Prefix Reserved
dotnet add package Soenneker.OpenAI.Moderation.HttpClients --version 4.0.68
NuGet\Install-Package Soenneker.OpenAI.Moderation.HttpClients -Version 4.0.68
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" Version="4.0.68" />
<PackageVersion Include="Soenneker.OpenAI.Moderation.HttpClients" Version="4.0.68" />
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" />
paket add Soenneker.OpenAI.Moderation.HttpClients --version 4.0.68
#r "nuget: Soenneker.OpenAI.Moderation.HttpClients, 4.0.68"
#:package Soenneker.OpenAI.Moderation.HttpClients@4.0.68
#addin nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=4.0.68
#tool nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=4.0.68
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 | net10.0 is compatible. 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. |
-
net10.0
- Soenneker.Extensions.Configuration (>= 4.0.898)
- Soenneker.Utils.HttpClientCache (>= 4.0.2101)
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 |
|---|---|---|
| 4.0.68 | 47 | 10/1/2026 |
| 4.0.67 | 48 | 9/30/2026 |
| 4.0.66 | 71 | 9/29/2026 |
| 4.0.65 | 66 | 9/29/2026 |
| 4.0.64 | 89 | 9/25/2026 |
| 4.0.63 | 81 | 9/25/2026 |
| 4.0.62 | 87 | 9/25/2026 |
| 4.0.61 | 93 | 9/25/2026 |
| 4.0.59 | 86 | 9/25/2026 |
| 4.0.58 | 86 | 9/24/2026 |
| 4.0.57 | 98 | 9/17/2026 |
| 4.0.56 | 97 | 9/16/2026 |
| 4.0.55 | 89 | 9/16/2026 |
| 4.0.54 | 92 | 9/16/2026 |
| 4.0.53 | 96 | 9/16/2026 |
| 4.0.52 | 90 | 9/15/2026 |
| 4.0.51 | 93 | 9/15/2026 |
| 4.0.50 | 108 | 9/13/2026 |
| 4.0.49 | 95 | 9/13/2026 |
| 4.0.48 | 93 | 9/13/2026 |