Soenneker.OpenAI.Moderation.HttpClients 11.0.100

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.OpenAI.Moderation.HttpClients --version 11.0.100
                    
NuGet\Install-Package Soenneker.OpenAI.Moderation.HttpClients -Version 11.0.100
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" Version="11.0.100" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.OpenAI.Moderation.HttpClients" Version="11.0.100" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.OpenAI.Moderation.HttpClients" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.OpenAI.Moderation.HttpClients --version 11.0.100
                    
#r "nuget: Soenneker.OpenAI.Moderation.HttpClients, 11.0.100"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.OpenAI.Moderation.HttpClients@11.0.100
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=11.0.100
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=11.0.100
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 118 11/19/2026
11.0.112 96 11/18/2026
11.0.109 94 11/18/2026
11.0.108 96 11/15/2026
11.0.107 99 11/15/2026
11.0.105 120 11/11/2026
11.0.104 101 11/11/2026
11.0.103 91 11/11/2026
11.0.102 96 11/11/2026
11.0.101 95 11/11/2026
11.0.100 118 11/3/2026
11.0.99 104 11/3/2026
11.0.98 100 11/3/2026
11.0.97 92 11/3/2026
11.0.96 117 10/27/2026
11.0.95 107 10/27/2026
11.0.93 108 10/26/2026
11.0.92 92 10/26/2026
11.0.90 92 10/26/2026
11.0.89 99 10/26/2026
Loading failed

Updated Multiple NuGet packages