Soenneker.OpenAI.Moderation
11.0.147
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.OpenAI.Moderation --version 11.0.147
NuGet\Install-Package Soenneker.OpenAI.Moderation -Version 11.0.147
<PackageReference Include="Soenneker.OpenAI.Moderation" Version="11.0.147" />
<PackageVersion Include="Soenneker.OpenAI.Moderation" Version="11.0.147" />
<PackageReference Include="Soenneker.OpenAI.Moderation" />
paket add Soenneker.OpenAI.Moderation --version 11.0.147
#r "nuget: Soenneker.OpenAI.Moderation, 11.0.147"
#:package Soenneker.OpenAI.Moderation@11.0.147
#addin nuget:?package=Soenneker.OpenAI.Moderation&version=11.0.147
#tool nuget:?package=Soenneker.OpenAI.Moderation&version=11.0.147
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.309)
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 | 242 | 11/19/2026 |
| 11.0.149 | 89 | 11/19/2026 |
| 11.0.148 | 84 | 11/19/2026 |
| 11.0.147 | 92 | 11/18/2026 |
| 11.0.145 | 97 | 11/17/2026 |
| 11.0.144 | 84 | 11/17/2026 |
| 11.0.143 | 102 | 11/15/2026 |
| 11.0.142 | 93 | 11/15/2026 |
| 11.0.141 | 188 | 11/11/2026 |
| 11.0.140 | 99 | 11/11/2026 |
| 11.0.138 | 109 | 11/11/2026 |
| 11.0.137 | 87 | 11/11/2026 |
| 11.0.136 | 102 | 11/11/2026 |
| 11.0.135 | 206 | 11/6/2026 |
| 11.0.134 | 119 | 11/5/2026 |
| 11.0.133 | 154 | 11/3/2026 |
| 11.0.132 | 103 | 11/3/2026 |
| 11.0.131 | 94 | 11/3/2026 |
| 11.0.130 | 97 | 11/3/2026 |
| 11.0.129 | 90 | 11/3/2026 |
Updated Multiple NuGet packages