Create moderation

POSThttps:/api.openai.com/v1/moderations

Classifies if text and/or image inputs are potentially harmful. Learn more in the moderation guide.

Request body

  • input
    string or array
    Input (or inputs) to classify. Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.
    • input
      string
      Required
      Defaults:
      A string of text to classify for moderation.
    • input
      array
      Required
      An array of strings to classify for moderation.
      • items
        string
        Defaults:
    • input
      array
      Required
      An array of multi-modal inputs to the moderation model.
      • items
        object
        An object describing an image to classify.
        • type
          string
          Required

          Always image_url.

          • image_url
            string
        • image_url
          object
          Required
          Contains either an image URL or a data URL for a base64 encoded image.
          • url
            string
            Required
            Either a URL of the image or the base64 encoded image data.
      • items
        object
        An object describing text to classify.
        • type
          string
          Required

          Always text.

          • text
            string
        • text
          string
          Required
          A string of text to classify.
  • model
    string

    The content moderation model you would like to use. Learn more in the moderation guide, and learn about available models here.

    • model
      string
    • model
      string
      • omni-moderation-latest
        string
      • omni-moderation-2024-09-26
        string
      • text-moderation-latest
        string
      • text-moderation-stable
        string

Response

A moderation object.

Example request
1
curl https://api.openai.com/v1/moderations \
2
-H "Content-Type: application/json" \
3
-H "Authorization: Bearer $OPENAI_API_KEY" \
4
-d '{
5
"input": "I want to kill them."
6
}'
Example response
1
{
2
"id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR",
3
"model": "text-moderation-007",
4
"results": [
5
{
6
"flagged": true,
7
"categories": {
8
"sexual": false,
9
"hate": false,
10
"harassment": true,
11
"self-harm": false,
12
"sexual/minors": false,
13
"hate/threatening": false,
14
"violence/graphic": false,
15
"self-harm/intent": false,
16
"self-harm/instructions": false,
17
"harassment/threatening": true,
18
"violence": true
19
},
20
"category_scores": {
21
"sexual": 0.000011726012417057063,
22
"hate": 0.22706663608551025,
23
"harassment": 0.5215635299682617,
24
"self-harm": 2.227119921371923e-6,
25
"sexual/minors": 7.107352217872176e-8,
26
"hate/threatening": 0.023547329008579254,
27
"violence/graphic": 0.00003391829886822961,
28
"self-harm/intent": 1.646940972932498e-6,
29
"self-harm/instructions": 1.1198755256458526e-9,
30
"harassment/threatening": 0.5694745779037476,
31
"violence": 0.9971134662628174
32
}
33
}
34
]
35
}
Built with