Repository Public
1# Moderations23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Create moderation67**post** `/moderations`89Classifies if text and/or image inputs are potentially harmful. Learn10more in the [moderation guide](/api/docs/guides/moderation).1112### Body Parameters1314- `input: string or array of string or array of object { image_url, type } or object { text, type }`1516 Input (or inputs) to classify. Can be a single string, an array of strings, or17 an array of multi-modal input objects similar to other models.1819 - `string`2021 A string of text to classify for moderation.2223 - `array of string`2425 An array of strings to classify for moderation.2627 - `array of object { image_url, type } or object { text, type }`2829 An array of multi-modal inputs to the moderation model.3031 - `ImageURL object { image_url, type }`3233 An object describing an image to classify.3435 - `image_url: object { url }`3637 Contains either an image URL or a data URL for a base64 encoded image.3839 - `url: string`4041 Either a URL of the image or the base64 encoded image data.4243 - `type: "image_url"`4445 Always `image_url`.4647 - `"image_url"`4849 - `Text object { text, type }`5051 An object describing text to classify.5253 - `text: string`5455 A string of text to classify.5657 - `type: "text"`5859 Always `text`.6061 - `"text"`6263- `model: optional string or ModerationModel`6465 The content moderation model you would like to use. Learn more in66 [the moderation guide](/api/docs/guides/moderation), and learn about67 available models [here](/api/docs/guides/moderation).6869 - `string`7071 - `ModerationModel = "omni-moderation-latest" or "omni-moderation-2024-09-26" or "text-moderation-latest" or "text-moderation-stable"`7273 - `"omni-moderation-latest"`7475 - `"omni-moderation-2024-09-26"`7677 - `"text-moderation-latest"`7879 - `"text-moderation-stable"`8081### Returns8283- `id: string`8485 The unique identifier for the moderation request.8687- `model: string`8889 The model used to generate the moderation results.9091- `results: array of Moderation`9293 A list of moderation objects.9495 - `categories: object { harassment, "harassment/threatening", hate, 10 more }`9697 A list of the categories, and whether they are flagged or not.9899 - `harassment: boolean`100101 Content that expresses, incites, or promotes harassing language towards any target.102103 - `"harassment/threatening": boolean`104105 Harassment content that also includes violence or serious harm towards any target.106107 - `hate: boolean`108109 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.110111 - `"hate/threatening": boolean`112113 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.114115 - `illicit: boolean or null`116117 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.118119 - `"illicit/violent": boolean or null`120121 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.122123 - `"self-harm": boolean`124125 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.126127 - `"self-harm/instructions": boolean`128129 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.130131 - `"self-harm/intent": boolean`132133 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.134135 - `sexual: boolean`136137 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).138139 - `"sexual/minors": boolean`140141 Sexual content that includes an individual who is under 18 years old.142143 - `violence: boolean`144145 Content that depicts death, violence, or physical injury.146147 - `"violence/graphic": boolean`148149 Content that depicts death, violence, or physical injury in graphic detail.150151 - `category_applied_input_types: object { harassment, "harassment/threatening", hate, 10 more }`152153 A list of the categories along with the input type(s) that the score applies to.154155 - `harassment: array of "text"`156157 The applied input type(s) for the category 'harassment'.158159 - `"text"`160161 - `"harassment/threatening": array of "text"`162163 The applied input type(s) for the category 'harassment/threatening'.164165 - `"text"`166167 - `hate: array of "text"`168169 The applied input type(s) for the category 'hate'.170171 - `"text"`172173 - `"hate/threatening": array of "text"`174175 The applied input type(s) for the category 'hate/threatening'.176177 - `"text"`178179 - `illicit: array of "text"`180181 The applied input type(s) for the category 'illicit'.182183 - `"text"`184185 - `"illicit/violent": array of "text"`186187 The applied input type(s) for the category 'illicit/violent'.188189 - `"text"`190191 - `"self-harm": array of "text" or "image"`192193 The applied input type(s) for the category 'self-harm'.194195 - `"text"`196197 - `"image"`198199 - `"self-harm/instructions": array of "text" or "image"`200201 The applied input type(s) for the category 'self-harm/instructions'.202203 - `"text"`204205 - `"image"`206207 - `"self-harm/intent": array of "text" or "image"`208209 The applied input type(s) for the category 'self-harm/intent'.210211 - `"text"`212213 - `"image"`214215 - `sexual: array of "text" or "image"`216217 The applied input type(s) for the category 'sexual'.218219 - `"text"`220221 - `"image"`222223 - `"sexual/minors": array of "text"`224225 The applied input type(s) for the category 'sexual/minors'.226227 - `"text"`228229 - `violence: array of "text" or "image"`230231 The applied input type(s) for the category 'violence'.232233 - `"text"`234235 - `"image"`236237 - `"violence/graphic": array of "text" or "image"`238239 The applied input type(s) for the category 'violence/graphic'.240241 - `"text"`242243 - `"image"`244245 - `category_scores: object { harassment, "harassment/threatening", hate, 10 more }`246247 A list of the categories along with their scores as predicted by model.248249 - `harassment: number`250251 The score for the category 'harassment'.252253 - `"harassment/threatening": number`254255 The score for the category 'harassment/threatening'.256257 - `hate: number`258259 The score for the category 'hate'.260261 - `"hate/threatening": number`262263 The score for the category 'hate/threatening'.264265 - `illicit: number`266267 The score for the category 'illicit'.268269 - `"illicit/violent": number`270271 The score for the category 'illicit/violent'.272273 - `"self-harm": number`274275 The score for the category 'self-harm'.276277 - `"self-harm/instructions": number`278279 The score for the category 'self-harm/instructions'.280281 - `"self-harm/intent": number`282283 The score for the category 'self-harm/intent'.284285 - `sexual: number`286287 The score for the category 'sexual'.288289 - `"sexual/minors": number`290291 The score for the category 'sexual/minors'.292293 - `violence: number`294295 The score for the category 'violence'.296297 - `"violence/graphic": number`298299 The score for the category 'violence/graphic'.300301 - `flagged: boolean`302303 Whether any of the below categories are flagged.304305### Example306307```http308curl https://api.openai.com/v1/moderations \309 -H 'Content-Type: application/json' \310 -H "Authorization: Bearer $OPENAI_API_KEY" \311 -d '{312 "input": "I want to kill them."313 }'314```315316#### Response317318```json319{320 "id": "id",321 "model": "model",322 "results": [323 {324 "categories": {325 "harassment": true,326 "harassment/threatening": true,327 "hate": true,328 "hate/threatening": true,329 "illicit": true,330 "illicit/violent": true,331 "self-harm": true,332 "self-harm/instructions": true,333 "self-harm/intent": true,334 "sexual": true,335 "sexual/minors": true,336 "violence": true,337 "violence/graphic": true338 },339 "category_applied_input_types": {340 "harassment": [341 "text"342 ],343 "harassment/threatening": [344 "text"345 ],346 "hate": [347 "text"348 ],349 "hate/threatening": [350 "text"351 ],352 "illicit": [353 "text"354 ],355 "illicit/violent": [356 "text"357 ],358 "self-harm": [359 "text"360 ],361 "self-harm/instructions": [362 "text"363 ],364 "self-harm/intent": [365 "text"366 ],367 "sexual": [368 "text"369 ],370 "sexual/minors": [371 "text"372 ],373 "violence": [374 "text"375 ],376 "violence/graphic": [377 "text"378 ]379 },380 "category_scores": {381 "harassment": 0,382 "harassment/threatening": 0,383 "hate": 0,384 "hate/threatening": 0,385 "illicit": 0,386 "illicit/violent": 0,387 "self-harm": 0,388 "self-harm/instructions": 0,389 "self-harm/intent": 0,390 "sexual": 0,391 "sexual/minors": 0,392 "violence": 0,393 "violence/graphic": 0394 },395 "flagged": true396 }397 ]398}399```400401### Image and text402403```http404curl https://api.openai.com/v1/moderations \405 -X POST \406 -H "Content-Type: application/json" \407 -H "Authorization: Bearer $OPENAI_API_KEY" \408 -d '{409 "model": "omni-moderation-latest",410 "input": [411 { "type": "text", "text": "...text to classify goes here..." },412 {413 "type": "image_url",414 "image_url": {415 "url": "https://example.com/image.png"416 }417 }418 ]419 }'420```421422#### Response423424```json425{426 "id": "modr-0d9740456c391e43c445bf0f010940c7",427 "model": "omni-moderation-latest",428 "results": [429 {430 "flagged": true,431 "categories": {432 "harassment": true,433 "harassment/threatening": true,434 "sexual": false,435 "hate": false,436 "hate/threatening": false,437 "illicit": false,438 "illicit/violent": false,439 "self-harm/intent": false,440 "self-harm/instructions": false,441 "self-harm": false,442 "sexual/minors": false,443 "violence": true,444 "violence/graphic": true445 },446 "category_scores": {447 "harassment": 0.8189693396524255,448 "harassment/threatening": 0.804985420696006,449 "sexual": 1.573112165348997e-6,450 "hate": 0.007562942636942845,451 "hate/threatening": 0.004208854591835476,452 "illicit": 0.030535955153511665,453 "illicit/violent": 0.008925306722380033,454 "self-harm/intent": 0.00023023930975076432,455 "self-harm/instructions": 0.0002293869201073356,456 "self-harm": 0.012598046106750154,457 "sexual/minors": 2.212566909570261e-8,458 "violence": 0.9999992735124786,459 "violence/graphic": 0.843064871157054460 },461 "category_applied_input_types": {462 "harassment": [463 "text"464 ],465 "harassment/threatening": [466 "text"467 ],468 "sexual": [469 "text",470 "image"471 ],472 "hate": [473 "text"474 ],475 "hate/threatening": [476 "text"477 ],478 "illicit": [479 "text"480 ],481 "illicit/violent": [482 "text"483 ],484 "self-harm/intent": [485 "text",486 "image"487 ],488 "self-harm/instructions": [489 "text",490 "image"491 ],492 "self-harm": [493 "text",494 "image"495 ],496 "sexual/minors": [497 "text"498 ],499 "violence": [500 "text",501 "image"502 ],503 "violence/graphic": [504 "text",505 "image"506 ]507 }508 }509 ]510}511```512513### Single string514515```http516curl https://api.openai.com/v1/moderations \517 -H "Content-Type: application/json" \518 -H "Authorization: Bearer $OPENAI_API_KEY" \519 -d '{520 "input": "I want to kill them."521 }'522```523524#### Response525526```json527{528 "id": "modr-AB8CjOTu2jiq12hp1AQPfeqFWaORR",529 "model": "text-moderation-007",530 "results": [531 {532 "flagged": true,533 "categories": {534 "sexual": false,535 "hate": false,536 "harassment": true,537 "self-harm": false,538 "sexual/minors": false,539 "hate/threatening": false,540 "violence/graphic": false,541 "self-harm/intent": false,542 "self-harm/instructions": false,543 "harassment/threatening": true,544 "violence": true545 },546 "category_scores": {547 "sexual": 0.000011726012417057063,548 "hate": 0.22706663608551025,549 "harassment": 0.5215635299682617,550 "self-harm": 2.227119921371923e-6,551 "sexual/minors": 7.107352217872176e-8,552 "hate/threatening": 0.023547329008579254,553 "violence/graphic": 0.00003391829886822961,554 "self-harm/intent": 1.646940972932498e-6,555 "self-harm/instructions": 1.1198755256458526e-9,556 "harassment/threatening": 0.5694745779037476,557 "violence": 0.9971134662628174558 }559 }560 ]561}562```563564## Domain Types565566### Moderation567568- `Moderation object { categories, category_applied_input_types, category_scores, flagged }`569570 - `categories: object { harassment, "harassment/threatening", hate, 10 more }`571572 A list of the categories, and whether they are flagged or not.573574 - `harassment: boolean`575576 Content that expresses, incites, or promotes harassing language towards any target.577578 - `"harassment/threatening": boolean`579580 Harassment content that also includes violence or serious harm towards any target.581582 - `hate: boolean`583584 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.585586 - `"hate/threatening": boolean`587588 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.589590 - `illicit: boolean or null`591592 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.593594 - `"illicit/violent": boolean or null`595596 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.597598 - `"self-harm": boolean`599600 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.601602 - `"self-harm/instructions": boolean`603604 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.605606 - `"self-harm/intent": boolean`607608 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.609610 - `sexual: boolean`611612 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).613614 - `"sexual/minors": boolean`615616 Sexual content that includes an individual who is under 18 years old.617618 - `violence: boolean`619620 Content that depicts death, violence, or physical injury.621622 - `"violence/graphic": boolean`623624 Content that depicts death, violence, or physical injury in graphic detail.625626 - `category_applied_input_types: object { harassment, "harassment/threatening", hate, 10 more }`627628 A list of the categories along with the input type(s) that the score applies to.629630 - `harassment: array of "text"`631632 The applied input type(s) for the category 'harassment'.633634 - `"text"`635636 - `"harassment/threatening": array of "text"`637638 The applied input type(s) for the category 'harassment/threatening'.639640 - `"text"`641642 - `hate: array of "text"`643644 The applied input type(s) for the category 'hate'.645646 - `"text"`647648 - `"hate/threatening": array of "text"`649650 The applied input type(s) for the category 'hate/threatening'.651652 - `"text"`653654 - `illicit: array of "text"`655656 The applied input type(s) for the category 'illicit'.657658 - `"text"`659660 - `"illicit/violent": array of "text"`661662 The applied input type(s) for the category 'illicit/violent'.663664 - `"text"`665666 - `"self-harm": array of "text" or "image"`667668 The applied input type(s) for the category 'self-harm'.669670 - `"text"`671672 - `"image"`673674 - `"self-harm/instructions": array of "text" or "image"`675676 The applied input type(s) for the category 'self-harm/instructions'.677678 - `"text"`679680 - `"image"`681682 - `"self-harm/intent": array of "text" or "image"`683684 The applied input type(s) for the category 'self-harm/intent'.685686 - `"text"`687688 - `"image"`689690 - `sexual: array of "text" or "image"`691692 The applied input type(s) for the category 'sexual'.693694 - `"text"`695696 - `"image"`697698 - `"sexual/minors": array of "text"`699700 The applied input type(s) for the category 'sexual/minors'.701702 - `"text"`703704 - `violence: array of "text" or "image"`705706 The applied input type(s) for the category 'violence'.707708 - `"text"`709710 - `"image"`711712 - `"violence/graphic": array of "text" or "image"`713714 The applied input type(s) for the category 'violence/graphic'.715716 - `"text"`717718 - `"image"`719720 - `category_scores: object { harassment, "harassment/threatening", hate, 10 more }`721722 A list of the categories along with their scores as predicted by model.723724 - `harassment: number`725726 The score for the category 'harassment'.727728 - `"harassment/threatening": number`729730 The score for the category 'harassment/threatening'.731732 - `hate: number`733734 The score for the category 'hate'.735736 - `"hate/threatening": number`737738 The score for the category 'hate/threatening'.739740 - `illicit: number`741742 The score for the category 'illicit'.743744 - `"illicit/violent": number`745746 The score for the category 'illicit/violent'.747748 - `"self-harm": number`749750 The score for the category 'self-harm'.751752 - `"self-harm/instructions": number`753754 The score for the category 'self-harm/instructions'.755756 - `"self-harm/intent": number`757758 The score for the category 'self-harm/intent'.759760 - `sexual: number`761762 The score for the category 'sexual'.763764 - `"sexual/minors": number`765766 The score for the category 'sexual/minors'.767768 - `violence: number`769770 The score for the category 'violence'.771772 - `"violence/graphic": number`773774 The score for the category 'violence/graphic'.775776 - `flagged: boolean`777778 Whether any of the below categories are flagged.779780### Moderation Create Response781782- `ModerationCreateResponse object { id, model, results }`783784 Represents if a given text input is potentially harmful.785786 - `id: string`787788 The unique identifier for the moderation request.789790 - `model: string`791792 The model used to generate the moderation results.793794 - `results: array of Moderation`795796 A list of moderation objects.797798 - `categories: object { harassment, "harassment/threatening", hate, 10 more }`799800 A list of the categories, and whether they are flagged or not.801802 - `harassment: boolean`803804 Content that expresses, incites, or promotes harassing language towards any target.805806 - `"harassment/threatening": boolean`807808 Harassment content that also includes violence or serious harm towards any target.809810 - `hate: boolean`811812 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.813814 - `"hate/threatening": boolean`815816 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.817818 - `illicit: boolean or null`819820 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.821822 - `"illicit/violent": boolean or null`823824 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.825826 - `"self-harm": boolean`827828 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.829830 - `"self-harm/instructions": boolean`831832 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.833834 - `"self-harm/intent": boolean`835836 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.837838 - `sexual: boolean`839840 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).841842 - `"sexual/minors": boolean`843844 Sexual content that includes an individual who is under 18 years old.845846 - `violence: boolean`847848 Content that depicts death, violence, or physical injury.849850 - `"violence/graphic": boolean`851852 Content that depicts death, violence, or physical injury in graphic detail.853854 - `category_applied_input_types: object { harassment, "harassment/threatening", hate, 10 more }`855856 A list of the categories along with the input type(s) that the score applies to.857858 - `harassment: array of "text"`859860 The applied input type(s) for the category 'harassment'.861862 - `"text"`863864 - `"harassment/threatening": array of "text"`865866 The applied input type(s) for the category 'harassment/threatening'.867868 - `"text"`869870 - `hate: array of "text"`871872 The applied input type(s) for the category 'hate'.873874 - `"text"`875876 - `"hate/threatening": array of "text"`877878 The applied input type(s) for the category 'hate/threatening'.879880 - `"text"`881882 - `illicit: array of "text"`883884 The applied input type(s) for the category 'illicit'.885886 - `"text"`887888 - `"illicit/violent": array of "text"`889890 The applied input type(s) for the category 'illicit/violent'.891892 - `"text"`893894 - `"self-harm": array of "text" or "image"`895896 The applied input type(s) for the category 'self-harm'.897898 - `"text"`899900 - `"image"`901902 - `"self-harm/instructions": array of "text" or "image"`903904 The applied input type(s) for the category 'self-harm/instructions'.905906 - `"text"`907908 - `"image"`909910 - `"self-harm/intent": array of "text" or "image"`911912 The applied input type(s) for the category 'self-harm/intent'.913914 - `"text"`915916 - `"image"`917918 - `sexual: array of "text" or "image"`919920 The applied input type(s) for the category 'sexual'.921922 - `"text"`923924 - `"image"`925926 - `"sexual/minors": array of "text"`927928 The applied input type(s) for the category 'sexual/minors'.929930 - `"text"`931932 - `violence: array of "text" or "image"`933934 The applied input type(s) for the category 'violence'.935936 - `"text"`937938 - `"image"`939940 - `"violence/graphic": array of "text" or "image"`941942 The applied input type(s) for the category 'violence/graphic'.943944 - `"text"`945946 - `"image"`947948 - `category_scores: object { harassment, "harassment/threatening", hate, 10 more }`949950 A list of the categories along with their scores as predicted by model.951952 - `harassment: number`953954 The score for the category 'harassment'.955956 - `"harassment/threatening": number`957958 The score for the category 'harassment/threatening'.959960 - `hate: number`961962 The score for the category 'hate'.963964 - `"hate/threatening": number`965966 The score for the category 'hate/threatening'.967968 - `illicit: number`969970 The score for the category 'illicit'.971972 - `"illicit/violent": number`973974 The score for the category 'illicit/violent'.975976 - `"self-harm": number`977978 The score for the category 'self-harm'.979980 - `"self-harm/instructions": number`981982 The score for the category 'self-harm/instructions'.983984 - `"self-harm/intent": number`985986 The score for the category 'self-harm/intent'.987988 - `sexual: number`989990 The score for the category 'sexual'.991992 - `"sexual/minors": number`993994 The score for the category 'sexual/minors'.995996 - `violence: number`997998 The score for the category 'violence'.9991000 - `"violence/graphic": number`10011002 The score for the category 'violence/graphic'.10031004 - `flagged: boolean`10051006 Whether any of the below categories are flagged.10071008### Moderation Model10091010- `ModerationModel = "omni-moderation-latest" or "omni-moderation-2024-09-26" or "text-moderation-latest" or "text-moderation-stable"`10111012 - `"omni-moderation-latest"`10131014 - `"omni-moderation-2024-09-26"`10151016 - `"text-moderation-latest"`10171018 - `"text-moderation-stable"`1019