Skip to main content
Analyze text content to detect potential policy violations including hate speech, violence, sexual content, self-harm, and harassment. This uses OpenAI’s moderation API to help ensure your application complies with usage policies.

Samples

Check content for violations

Analyze text for potentially harmful content:
Returns a JSON object with flagged categories and confidence scores:

Check if content is flagged

Get a simple boolean result:

Filter by specific categories

Check for specific types of violations:

Moderate user-generated content with triggers

Automatically flag problematic content:

Arguments

Returns

JSONB: A JSON object containing moderation results with the following structure:
  • id: Unique identifier for the moderation request
  • model: The model used
  • results: Array of result objects (one per input)
    • flagged: Boolean indicating if content was flagged
    • categories: Object with boolean flags for each category
      • hate, hate/threatening
      • harassment, harassment/threatening
      • self-harm, self-harm/intent, self-harm/instructions
      • sexual, sexual/minors
      • violence, violence/graphic
    • category_scores: Object with confidence scores (0-1) for each category