Moderate content with OpenAI
openai_moderate_contentCheck any text against OpenAI's moderation policy and get flagged categories with confidence scores, so you can reject or review unsafe content before publishing or forwarding user input.
Instructions
Check text against OpenAI's moderation policy and report which categories it triggers.
Use this before publishing or forwarding user-supplied text, or to explain why a generation was refused.
Args:
input (string, required): the text to check
model (string): moderation model ID, defaults to OPENAI_DEFAULT_MODERATION_MODEL
response_format ('markdown'|'json'): default 'markdown'
Returns (JSON format): { "model": string, "flagged": boolean, // true when any category was triggered "flagged_categories": string[], // e.g. ["violence", "harassment/threatening"] "scores": { "": number } // confidence per category, 0.0-1.0 }
Examples:
Use when: "Is this user comment acceptable?" -> input=
Use when: auditing a batch of support messages before archiving them
Don't use when: you need a stylistic or factual review (use openai_generate_text)
Error Handling:
"Error: Not found" means the moderation model ID is wrong — call openai_list_models with filter="moderation"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The text to check | |
| model | No | Moderation model ID. Defaults to OPENAI_DEFAULT_MODERATION_MODEL. | |
| response_format | No | Output format: 'markdown' or 'json' | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| scores | Yes | ||
| flagged | Yes | ||
| flagged_categories | Yes |