https://github.com/soenneker/soenneker.openai.moderation
A .NET OpenAI content moderation utility using their OpenAPI client
https://github.com/soenneker/soenneker.openai.moderation
content csharp dotnet moderation openai openaimoderationutil util
Last synced: 7 days ago
JSON representation
A .NET OpenAI content moderation utility using their OpenAPI client
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.openai.moderation
- Owner: soenneker
- License: mit
- Created: 2026-06-19T18:47:53.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-20T01:52:02.000Z (about 1 month ago)
- Last Synced: 2026-07-03T17:08:18.303Z (21 days ago)
- Topics: content, csharp, dotnet, moderation, openai, openaimoderationutil, util
- Language: C#
- Homepage: https://soenneker.com
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.openai.moderation/)
[](https://github.com/soenneker/soenneker.openai.moderation/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.openai.moderation/)
#  Soenneker.OpenAI.Moderation
### A .NET OpenAI content moderation utility using their OpenAPI client
## Installation
```
dotnet add package Soenneker.OpenAI.Moderation
```
## Usage
```csharp
using Soenneker.OpenAI.Moderation.Abstract;
using Soenneker.OpenAI.Moderation.Extensions;
using Soenneker.OpenAI.Moderation.Registrars;
using Soenneker.OpenAI.OpenApiClient.Models;
services.AddOpenAIModerationUtilAsScoped();
CreateModerationResponse? response = await moderationUtil.Moderate("content to check", cancellationToken);
if (response.IsFlagged())
{
string? category = response.GetFirstFlaggedCategoryValue();
}
```
Configuration defaults:
```json
{
"OpenAI": {
"ApiKey": "...",
"Moderation": {
"Enabled": true,
"Model": "omni-moderation-latest",
"SkipWhenApiKeyMissing": true
}
}
}
```