Prerequisites

You'll need an API key to use the Moderation API. To get one, you'll need to create a project.

1. Install dependencies

We currently don’t have an official SDK for .NET, but you can use the OpenAPI Generator to generate a .NET client or simply call the API directly using HttpClient.
dotnet add package System.Text.Json

2. Submit content

Grab the API key from your project and begin submitting text, images, or other media to your project for moderation.
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

public class ModerationClient
{
    private readonly HttpClient _httpClient;
    private const string BaseUrl = "https://moderationapi.com/api/v1";

    public ModerationClient(string apiKey)
    {
        _httpClient = new HttpClient();
        _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
    }

    public async Task<TextModerationResult> ModerateTextAsync(string text, string authorId = "123", string contextId = "456")
    {
        var payload = new
        {
            value = text,
            authorId = authorId,
            contextId = contextId,
            metadata = new { customField = "value" }
        };

        var json = JsonSerializer.Serialize(payload);
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        var response = await _httpClient.PostAsync($"{BaseUrl}/moderate/text", content);
        response.EnsureSuccessStatusCode();

        var responseContent = await response.Content.ReadAsStringAsync();
        return JsonSerializer.Deserialize<TextModerationResult>(responseContent);
    }
}

public class TextModerationResult
{
    public bool flagged { get; set; }
    public object[] categories { get; set; }
}

// Usage example
class Program
{
    static async Task Main(string[] args)
    {
        var client = new ModerationClient("your-api-key"); // Replace with your API key

        var result = await client.ModerateTextAsync("Hello world!");

        if (result.flagged)
        {
            Console.WriteLine("Text content flagged");
            // Block the content, show an error, etc...
        }
        else
        {
            Console.WriteLine("Text content is safe.");
            // Save to database or proceed...
        }
    }
}

Dry-run mode: If you want to analyze production data but don't want to block content, enable "dry-run" in your project settings.
With dry-run enabled, the API still analyzes content but it always returns flagged: false - yet content still shows in the review queue. This way you can implement your moderation workflows and start testing your project configuration without actually blocking content.

3. Review flagged content (optional)

If the AI flags the content, it will appear in the Review Queue. Head to the review queue to validate that the content is submitted correctly.
Review queue for reviewing and improving automated moderation

Review queue for reviewing and improving automated moderation

You can use review queues to implement moderation workflows or simply check how the AI is performing.

All Done!

Congratulations! You've run your first moderation checks. Here are a few next steps:
  • Continue tweaking your project settings and models to find the best moderation outcomes.
  • Create an AI agent and add your guidelines to it.
  • Explore advanced features like context-aware moderation.
  • If you have questions, reach out to our support team.
We love hearing from you—please share how you're using the service and let us know if you have suggestions or need help. Happy moderating!