SPB Git

Repository Public

create.md 13.5 KB 561 lines markdown

1> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.23## Create moderation45**post** `/moderations`67Classifies if text and/or image inputs are potentially harmful. Learn8more in the [moderation guide](/api/docs/guides/moderation).910### Body Parameters1112- `input: string or array of string or array of object { image_url, type }  or object { text, type }`1314  Input (or inputs) to classify. Can be a single string, an array of strings, or15  an array of multi-modal input objects similar to other models.1617  - `string`1819    A string of text to classify for moderation.2021  - `array of string`2223    An array of strings to classify for moderation.2425  - `array of object { image_url, type }  or object { text, type }`2627    An array of multi-modal inputs to the moderation model.2829    - `ImageURL object { image_url, type }`3031      An object describing an image to classify.3233      - `image_url: object { url }`3435        Contains either an image URL or a data URL for a base64 encoded image.3637        - `url: string`3839          Either a URL of the image or the base64 encoded image data.4041      - `type: "image_url"`4243        Always `image_url`.4445        - `"image_url"`4647    - `Text object { text, type }`4849      An object describing text to classify.5051      - `text: string`5253        A string of text to classify.5455      - `type: "text"`5657        Always `text`.5859        - `"text"`6061- `model: optional string or ModerationModel`6263  The content moderation model you would like to use. Learn more in64  [the moderation guide](/api/docs/guides/moderation), and learn about65  available models [here](/api/docs/guides/moderation).6667  - `string`6869  - `ModerationModel = "omni-moderation-latest" or "omni-moderation-2024-09-26" or "text-moderation-latest" or "text-moderation-stable"`7071    - `"omni-moderation-latest"`7273    - `"omni-moderation-2024-09-26"`7475    - `"text-moderation-latest"`7677    - `"text-moderation-stable"`7879### Returns8081- `id: string`8283  The unique identifier for the moderation request.8485- `model: string`8687  The model used to generate the moderation results.8889- `results: array of Moderation`9091  A list of moderation objects.9293  - `categories: object { harassment, "harassment/threatening", hate, 10 more }`9495    A list of the categories, and whether they are flagged or not.9697    - `harassment: boolean`9899      Content that expresses, incites, or promotes harassing language towards any target.100101    - `"harassment/threatening": boolean`102103      Harassment content that also includes violence or serious harm towards any target.104105    - `hate: boolean`106107      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.108109    - `"hate/threatening": boolean`110111      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.112113    - `illicit: boolean or null`114115      Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.116117    - `"illicit/violent": boolean or null`118119      Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.120121    - `"self-harm": boolean`122123      Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.124125    - `"self-harm/instructions": boolean`126127      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.128129    - `"self-harm/intent": boolean`130131      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.132133    - `sexual: boolean`134135      Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).136137    - `"sexual/minors": boolean`138139      Sexual content that includes an individual who is under 18 years old.140141    - `violence: boolean`142143      Content that depicts death, violence, or physical injury.144145    - `"violence/graphic": boolean`146147      Content that depicts death, violence, or physical injury in graphic detail.148149  - `category_applied_input_types: object { harassment, "harassment/threatening", hate, 10 more }`150151    A list of the categories along with the input type(s) that the score applies to.152153    - `harassment: array of "text"`154155      The applied input type(s) for the category 'harassment'.156157      - `"text"`158159    - `"harassment/threatening": array of "text"`160161      The applied input type(s) for the category 'harassment/threatening'.162163      - `"text"`164165    - `hate: array of "text"`166167      The applied input type(s) for the category 'hate'.168169      - `"text"`170171    - `"hate/threatening": array of "text"`172173      The applied input type(s) for the category 'hate/threatening'.174175      - `"text"`176177    - `illicit: array of "text"`178179      The applied input type(s) for the category 'illicit'.180181      - `"text"`182183    - `"illicit/violent": array of "text"`184185      The applied input type(s) for the category 'illicit/violent'.186187      - `"text"`188189    - `"self-harm": array of "text" or "image"`190191      The applied input type(s) for the category 'self-harm'.192193      - `"text"`194195      - `"image"`196197    - `"self-harm/instructions": array of "text" or "image"`198199      The applied input type(s) for the category 'self-harm/instructions'.200201      - `"text"`202203      - `"image"`204205    - `"self-harm/intent": array of "text" or "image"`206207      The applied input type(s) for the category 'self-harm/intent'.208209      - `"text"`210211      - `"image"`212213    - `sexual: array of "text" or "image"`214215      The applied input type(s) for the category 'sexual'.216217      - `"text"`218219      - `"image"`220221    - `"sexual/minors": array of "text"`222223      The applied input type(s) for the category 'sexual/minors'.224225      - `"text"`226227    - `violence: array of "text" or "image"`228229      The applied input type(s) for the category 'violence'.230231      - `"text"`232233      - `"image"`234235    - `"violence/graphic": array of "text" or "image"`236237      The applied input type(s) for the category 'violence/graphic'.238239      - `"text"`240241      - `"image"`242243  - `category_scores: object { harassment, "harassment/threatening", hate, 10 more }`244245    A list of the categories along with their scores as predicted by model.246247    - `harassment: number`248249      The score for the category 'harassment'.250251    - `"harassment/threatening": number`252253      The score for the category 'harassment/threatening'.254255    - `hate: number`256257      The score for the category 'hate'.258259    - `"hate/threatening": number`260261      The score for the category 'hate/threatening'.262263    - `illicit: number`264265      The score for the category 'illicit'.266267    - `"illicit/violent": number`268269      The score for the category 'illicit/violent'.270271    - `"self-harm": number`272273      The score for the category 'self-harm'.274275    - `"self-harm/instructions": number`276277      The score for the category 'self-harm/instructions'.278279    - `"self-harm/intent": number`280281      The score for the category 'self-harm/intent'.282283    - `sexual: number`284285      The score for the category 'sexual'.286287    - `"sexual/minors": number`288289      The score for the category 'sexual/minors'.290291    - `violence: number`292293      The score for the category 'violence'.294295    - `"violence/graphic": number`296297      The score for the category 'violence/graphic'.298299  - `flagged: boolean`300301    Whether any of the below categories are flagged.302303### Example304305```http306curl https://api.openai.com/v1/moderations \307    -H 'Content-Type: application/json' \308    -H "Authorization: Bearer $OPENAI_API_KEY" \309    -d '{310          "input": "I want to kill them."311        }'312```313314#### Response315316```json317{318  "id": "id",319  "model": "model",320  "results": [321    {322      "categories": {323        "harassment": true,324        "harassment/threatening": true,325        "hate": true,326        "hate/threatening": true,327        "illicit": true,328        "illicit/violent": true,329        "self-harm": true,330        "self-harm/instructions": true,331        "self-harm/intent": true,332        "sexual": true,333        "sexual/minors": true,334        "violence": true,335        "violence/graphic": true336      },337      "category_applied_input_types": {338        "harassment": [339          "text"340        ],341        "harassment/threatening": [342          "text"343        ],344        "hate": [345          "text"346        ],347        "hate/threatening": [348          "text"349        ],350        "illicit": [351          "text"352        ],353        "illicit/violent": [354          "text"355        ],356        "self-harm": [357          "text"358        ],359        "self-harm/instructions": [360          "text"361        ],362        "self-harm/intent": [363          "text"364        ],365        "sexual": [366          "text"367        ],368        "sexual/minors": [369          "text"370        ],371        "violence": [372          "text"373        ],374        "violence/graphic": [375          "text"376        ]377      },378      "category_scores": {379        "harassment": 0,380        "harassment/threatening": 0,381        "hate": 0,382        "hate/threatening": 0,383        "illicit": 0,384        "illicit/violent": 0,385        "self-harm": 0,386        "self-harm/instructions": 0,387        "self-harm/intent": 0,388        "sexual": 0,389        "sexual/minors": 0,390        "violence": 0,391        "violence/graphic": 0392      },393      "flagged": true394    }395  ]396}397```398399### Image and text400401```http402curl https://api.openai.com/v1/moderations \403  -X POST \404  -H "Content-Type: application/json" \405  -H "Authorization: Bearer $OPENAI_API_KEY" \406  -d '{407    "model": "omni-moderation-latest",408    "input": [409      { "type": "text", "text": "...text to classify goes here..." },410      {411        "type": "image_url",412        "image_url": {413          "url": "https://example.com/image.png"414        }415      }416    ]417  }'418```419420#### Response421422```json423{424  "id": "modr-0d9740456c391e43c445bf0f010940c7",425  "model": "omni-moderation-latest",426  "results": [427    {428      "flagged": true,429      "categories": {430        "harassment": true,431        "harassment/threatening": true,432        "sexual": false,433        "hate": false,434        "hate/threatening": false,435        "illicit": false,436        "illicit/violent": false,437        "self-harm/intent": false,438        "self-harm/instructions": false,439        "self-harm": false,440        "sexual/minors": false,441        "violence": true,442        "violence/graphic": true443      },444      "category_scores": {445        "harassment": 0.8189693396524255,446        "harassment/threatening": 0.804985420696006,447        "sexual": 1.573112165348997e-6,448        "hate": 0.007562942636942845,449        "hate/threatening": 0.004208854591835476,450        "illicit": 0.030535955153511665,451        "illicit/violent": 0.008925306722380033,452        "self-harm/intent": 0.00023023930975076432,453        "self-harm/instructions": 0.0002293869201073356,454        "self-harm": 0.012598046106750154,455        "sexual/minors": 2.212566909570261e-8,456        "violence": 0.9999992735124786,457        "violence/graphic": 0.843064871157054458      },459      "category_applied_input_types": {460        "harassment": [461          "text"462        ],463        "harassment/threatening": [464          "text"465        ],466        "sexual": [467          "text",468          "image"469        ],470        "hate": [471          "text"472        ],473        "hate/threatening": [474          "text"475        ],476        "illicit": [477          "text"478        ],479        "illicit/violent": [480          "text"481        ],482        "self-harm/intent": [483          "text",484          "image"485        ],486        "self-harm/instructions": [487          "text",488          "image"489        ],490        "self-harm": [491          "text",492          "image"493        ],494        "sexual/minors": [495          "text"496        ],497        "violence": [498          "text",499          "image"500        ],501        "violence/graphic": [502          "text",503          "image"504        ]505      }506    }507  ]508}509```510511### Single string512513```http514curl https://api.openai.com/v1/moderations \515  -H "Content-Type: application/json" \516  -H "Authorization: Bearer $OPENAI_API_KEY" \517  -d '{518    "input": "I want to kill them."519  }'520```521522#### Response523524```json525{526  "id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR",527  "model": "text-moderation-007",528  "results": [529    {530      "flagged": true,531      "categories": {532        "sexual": false,533        "hate": false,534        "harassment": true,535        "self-harm": false,536        "sexual/minors": false,537        "hate/threatening": false,538        "violence/graphic": false,539        "self-harm/intent": false,540        "self-harm/instructions": false,541        "harassment/threatening": true,542        "violence": true543      },544      "category_scores": {545        "sexual": 0.000011726012417057063,546        "hate": 0.22706663608551025,547        "harassment": 0.5215635299682617,548        "self-harm": 2.227119921371923e-6,549        "sexual/minors": 7.107352217872176e-8,550        "hate/threatening": 0.023547329008579254,551        "violence/graphic": 0.00003391829886822961,552        "self-harm/intent": 1.646940972932498e-6,553        "self-harm/instructions": 1.1198755256458526e-9,554        "harassment/threatening": 0.5694745779037476,555        "violence": 0.9971134662628174556      }557    }558  ]559}560```561
Files main
Menu

Theme