Samples
Check content for violations
Analyze text for potentially harmful content: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
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
model | TEXT | - | ✔ | The moderation model to use (e.g., text-moderation-latest, text-moderation-stable) |
input_text | TEXT | - | ✔ | The text content to analyze |
api_key | TEXT | NULL | ✖ | OpenAI API key. If not provided, uses ai.openai_api_key setting |
api_key_name | TEXT | NULL | ✖ | Name of the secret containing the API key |
extra_headers | JSONB | NULL | ✖ | Additional HTTP headers to include in the API request |
extra_query | JSONB | NULL | ✖ | Additional query parameters for the API request |
verbose | BOOLEAN | FALSE | ✖ | Enable verbose logging for debugging |
client_config | JSONB | NULL | ✖ | Advanced client configuration options |
Returns
JSONB: A JSON object containing moderation results with the following structure:
id: Unique identifier for the moderation requestmodel: The model usedresults: Array of result objects (one per input)flagged: Boolean indicating if content was flaggedcategories: Object with boolean flags for each categoryhate,hate/threateningharassment,harassment/threateningself-harm,self-harm/intent,self-harm/instructionssexual,sexual/minorsviolence,violence/graphic
category_scores: Object with confidence scores (0-1) for each category
Related functions
openai_moderate_with_raw_response(): get the full HTTP response