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
                    
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="4.0.68" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.OpenAI.Moderation.HttpClients" Version="4.0.68" />
                    
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 4.0.68
                    
#r "nuget: Soenneker.OpenAI.Moderation.HttpClients, 4.0.68"
                    
#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@4.0.68
                    
#: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=4.0.68
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.OpenAI.Moderation.HttpClients&version=4.0.68
                    
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 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. 
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
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
Loading failed