Create moderation

POST /moderations

Classifies if text is potentially harmful.

application/json

Body Required

  • input string | array[string] Required

    One of:

    The input text to classify

    Default value is empty.

    The input text to classify

    Default value is empty.

  • model string

    Any of:

    Two content moderations models are available: text-moderation-stable and text-moderation-latest.

    The default is text-moderation-latest which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.

    Default value is text-moderation-latest.

    Two content moderations models are available: text-moderation-stable and text-moderation-latest.

    The default is text-moderation-latest which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.

    Values are text-moderation-latest or text-moderation-stable. Default value is text-moderation-latest.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • id string Required

      The unique identifier for the moderation request.

    • model string Required

      The model used to generate the moderation results.

    • results array[object] Required

      A list of moderation objects.

      Hide results attributes Show results attributes object
      • flagged boolean Required

        Whether any of the below categories are flagged.

      • categories object Required

        A list of the categories, and whether they are flagged or not.

        Hide categories attributes Show categories attributes object
        • hate boolean Required

          Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.

        • hate/threatening boolean Required

          Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.

        • harassment boolean Required

          Content that expresses, incites, or promotes harassing language towards any target.

        • harassment/threatening boolean Required

          Harassment content that also includes violence or serious harm towards any target.

        • self-harm boolean Required

          Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.

        • self-harm/intent boolean Required

          Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.

        • self-harm/instructions boolean Required

          Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.

        • sexual boolean Required

          Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).

        • sexual/minors boolean Required

          Sexual content that includes an individual who is under 18 years old.

        • violence boolean Required

          Content that depicts death, violence, or physical injury.

        • violence/graphic boolean Required

          Content that depicts death, violence, or physical injury in graphic detail.

      • category_scores object Required

        A list of the categories along with their scores as predicted by model.

        Hide category_scores attributes Show category_scores attributes object
POST /moderations
curl \
 -X POST https://api.openai.com/v1/moderations \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"input":"I want to kill them.","model":"text-moderation-stable"}'
Request example
{
  "input": "I want to kill them.",
  "model": "text-moderation-stable"
}
Response examples (200)
{
  "id": "string",
  "model": "string",
  "results": [
    {
      "flagged": true,
      "categories": {
        "hate": true,
        "hate/threatening": true,
        "harassment": true,
        "harassment/threatening": true,
        "self-harm": true,
        "self-harm/intent": true,
        "self-harm/instructions": true,
        "sexual": true,
        "sexual/minors": true,
        "violence": true,
        "violence/graphic": true
      },
      "category_scores": {
        "hate": 42.0,
        "hate/threatening": 42.0,
        "harassment": 42.0,
        "harassment/threatening": 42.0,
        "self-harm": 42.0,
        "self-harm/intent": 42.0,
        "self-harm/instructions": 42.0,
        "sexual": 42.0,
        "sexual/minors": 42.0,
        "violence": 42.0,
        "violence/graphic": 42.0
      }
    }
  ]
}