Soenneker.OpenAI.Moderation
11.0.136
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.OpenAI.Moderation --version 11.0.136
NuGet\Install-Package Soenneker.OpenAI.Moderation -Version 11.0.136
<PackageReference Include="Soenneker.OpenAI.Moderation" Version="11.0.136" />
<PackageVersion Include="Soenneker.OpenAI.Moderation" Version="11.0.136" />
<PackageReference Include="Soenneker.OpenAI.Moderation" />
paket add Soenneker.OpenAI.Moderation --version 11.0.136
#r "nuget: Soenneker.OpenAI.Moderation, 11.0.136"
#:package Soenneker.OpenAI.Moderation@11.0.136
#addin nuget:?package=Soenneker.OpenAI.Moderation&version=11.0.136
#tool nuget:?package=Soenneker.OpenAI.Moderation&version=11.0.136
Soenneker.OpenAI.Moderation
Moderate text with OpenAI and inspect flagged categories through typed response helpers.
Installation
dotnet add package Soenneker.OpenAI.Moderation
Registration and configuration
Register the scoped utility during application startup:
using Soenneker.OpenAI.Moderation.Registrars;
services.AddOpenAIModerationUtilAsScoped();
The scoped registration keeps the utility scoped while reusing the singleton OpenAI client. A singleton utility registration is also available through AddOpenAIModerationUtilAsSingleton().
Provide the API key through configuration. Enabled defaults to true, and Model defaults to omni-moderation-latest when omitted:
{
"OpenAI": {
"ApiKey": "...",
"Moderation": {
"Enabled": true,
"Model": "omni-moderation-latest"
}
}
}
Keep the API key in a secret store or environment variable rather than committed configuration.
Moderate text
Inject IOpenAIModerationUtil, then inspect the returned OpenAI response directly or use the supplied helpers:
using Soenneker.OpenAI.Moderation.Abstract;
using Soenneker.OpenAI.Moderation.Extensions;
using Soenneker.OpenAI.OpenApiClient.Models;
CreateModerationResponse? response = await moderationUtil.Moderate("content to check", cancellationToken);
if (response.IsFlagged())
{
IReadOnlyList<string> categories = response.GetFlaggedCategoryValues();
}
Moderate returns null when moderation is disabled, the input is empty, or every item in a batch is blank. API and transport failures are allowed to propagate to the caller.
Moderate several inputs in one request:
CreateModerationResponse? response = await moderationUtil.Moderate(
["first message", "second message"],
cancellationToken);
Use per-call options when behavior should differ from configuration:
var options = new OpenAIModerationOptions
{
Enabled = true,
Model = "omni-moderation-latest"
};
CreateModerationResponse? response = await moderationUtil.Moderate(
"content to check",
options,
cancellationToken);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.OpenAI.OpenApiClientUtil (>= 11.0.299)
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.150 | 145 | 11/19/2026 |
| 11.0.149 | 75 | 11/19/2026 |
| 11.0.148 | 69 | 11/19/2026 |
| 11.0.147 | 80 | 11/18/2026 |
| 11.0.145 | 85 | 11/17/2026 |
| 11.0.144 | 72 | 11/17/2026 |
| 11.0.143 | 98 | 11/15/2026 |
| 11.0.142 | 89 | 11/15/2026 |
| 11.0.141 | 184 | 11/11/2026 |
| 11.0.140 | 96 | 11/11/2026 |
| 11.0.138 | 107 | 11/11/2026 |
| 11.0.137 | 84 | 11/11/2026 |
| 11.0.136 | 99 | 11/11/2026 |
| 11.0.135 | 203 | 11/6/2026 |
| 11.0.134 | 115 | 11/5/2026 |
| 11.0.133 | 149 | 11/3/2026 |
| 11.0.132 | 101 | 11/3/2026 |
| 11.0.131 | 92 | 11/3/2026 |
| 11.0.130 | 95 | 11/3/2026 |
| 11.0.129 | 88 | 11/3/2026 |
Upgrade .NET 11 release candidates to stable