> ## Documentation Index
> Fetch the complete documentation index at: https://openai-hd4n6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create moderation

> Classifies if text and/or image inputs are potentially harmful. Learn more in the [moderation guide](/docs/guides/moderation).



## OpenAPI

````yaml api-definition.yaml post /moderations
openapi: 3.0.0
info:
  title: OpenAI API
  description: >-
    The OpenAI REST API. Please see
    https://platform.openai.com/docs/api-reference for more details.
  version: 2.3.0
  termsOfService: https://openai.com/policies/terms-of-use
  contact:
    name: OpenAI Support
    url: https://help.openai.com/
  license:
    name: MIT
    url: https://github.com/openai/openai-openapi/blob/master/LICENSE
servers:
  - url: https://api.openai.com/v1
security:
  - ApiKeyAuth: []
tags:
  - name: Assistants
    description: Build Assistants that can call models and use tools.
  - name: Audio
    description: Turn audio into text or text into audio.
  - name: Chat
    description: >-
      Given a list of messages comprising a conversation, the model will return
      a response.
  - name: Completions
    description: >-
      Given a prompt, the model will return one or more predicted completions,
      and can also return the probabilities of alternative tokens at each
      position.
  - name: Embeddings
    description: >-
      Get a vector representation of a given input that can be easily consumed
      by machine learning models and algorithms.
  - name: Evals
    description: Manage and run evals in the OpenAI platform.
  - name: Fine-tuning
    description: Manage fine-tuning jobs to tailor a model to your specific training data.
  - name: Batch
    description: Create large batches of API requests to run asynchronously.
  - name: Files
    description: >-
      Files are used to upload documents that can be used with features like
      Assistants and Fine-tuning.
  - name: Uploads
    description: Use Uploads to upload large files in multiple parts.
  - name: Images
    description: Given a prompt and/or an input image, the model will generate a new image.
  - name: Models
    description: List and describe the various models available in the API.
  - name: Moderations
    description: >-
      Given text and/or image inputs, classifies if those inputs are potentially
      harmful.
  - name: Audit Logs
    description: List user actions and configuration changes within this organization.
paths:
  /moderations:
    post:
      tags:
        - Moderations
      summary: Create moderation
      description: >-
        Classifies if text and/or image inputs are potentially harmful. Learn
        more in the [moderation guide](/docs/guides/moderation).
      operationId: createModeration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateModerationRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateModerationResponse'
components:
  schemas:
    CreateModerationRequest:
      type: object
      properties:
        input:
          description: >
            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.
          oneOf:
            - type: string
              description: A string of text to classify for moderation.
              default: ''
              example: I want to kill them.
            - type: array
              description: An array of strings to classify for moderation.
              items:
                type: string
                default: ''
                example: I want to kill them.
            - type: array
              description: An array of multi-modal inputs to the moderation model.
              items:
                x-oaiExpandable: true
                oneOf:
                  - type: object
                    description: An object describing an image to classify.
                    properties:
                      type:
                        description: Always `image_url`.
                        type: string
                        enum:
                          - image_url
                        x-stainless-const: true
                      image_url:
                        type: object
                        description: >-
                          Contains either an image URL or a data URL for a
                          base64 encoded image.
                        properties:
                          url:
                            type: string
                            description: >-
                              Either a URL of the image or the base64 encoded
                              image data.
                            format: uri
                            example: https://example.com/image.jpg
                        required:
                          - url
                    required:
                      - type
                      - image_url
                  - type: object
                    description: An object describing text to classify.
                    properties:
                      type:
                        description: Always `text`.
                        type: string
                        enum:
                          - text
                        x-stainless-const: true
                      text:
                        description: A string of text to classify.
                        type: string
                        example: I want to kill them
                    required:
                      - type
                      - text
          x-oaiExpandable: true
        model:
          description: |
            The content moderation model you would like to use. Learn more in
            [the moderation guide](/docs/guides/moderation), and learn about
            available models [here](/docs/models#moderation).
          nullable: false
          default: omni-moderation-latest
          example: omni-moderation-2024-09-26
          anyOf:
            - type: string
            - type: string
              enum:
                - omni-moderation-latest
                - omni-moderation-2024-09-26
                - text-moderation-latest
                - text-moderation-stable
          x-oaiTypeLabel: string
      required:
        - input
    CreateModerationResponse:
      type: object
      description: Represents if a given text input is potentially harmful.
      properties:
        id:
          type: string
          description: The unique identifier for the moderation request.
        model:
          type: string
          description: The model used to generate the moderation results.
        results:
          type: array
          description: A list of moderation objects.
          items:
            type: object
            properties:
              flagged:
                type: boolean
                description: Whether any of the below categories are flagged.
              categories:
                type: object
                description: A list of the categories, and whether they are flagged or not.
                properties:
                  hate:
                    type: boolean
                    description: >-
                      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:
                    type: boolean
                    description: >-
                      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:
                    type: boolean
                    description: >-
                      Content that expresses, incites, or promotes harassing
                      language towards any target.
                  harassment/threatening:
                    type: boolean
                    description: >-
                      Harassment content that also includes violence or serious
                      harm towards any target.
                  illicit:
                    type: boolean
                    nullable: true
                    description: >-
                      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.
                  illicit/violent:
                    type: boolean
                    nullable: true
                    description: >-
                      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.
                  self-harm:
                    type: boolean
                    description: >-
                      Content that promotes, encourages, or depicts acts of
                      self-harm, such as suicide, cutting, and eating disorders.
                  self-harm/intent:
                    type: boolean
                    description: >-
                      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:
                    type: boolean
                    description: >-
                      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:
                    type: boolean
                    description: >-
                      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:
                    type: boolean
                    description: >-
                      Sexual content that includes an individual who is under 18
                      years old.
                  violence:
                    type: boolean
                    description: Content that depicts death, violence, or physical injury.
                  violence/graphic:
                    type: boolean
                    description: >-
                      Content that depicts death, violence, or physical injury
                      in graphic detail.
                required:
                  - hate
                  - hate/threatening
                  - harassment
                  - harassment/threatening
                  - illicit
                  - illicit/violent
                  - self-harm
                  - self-harm/intent
                  - self-harm/instructions
                  - sexual
                  - sexual/minors
                  - violence
                  - violence/graphic
              category_scores:
                type: object
                description: >-
                  A list of the categories along with their scores as predicted
                  by model.
                properties:
                  hate:
                    type: number
                    description: The score for the category 'hate'.
                  hate/threatening:
                    type: number
                    description: The score for the category 'hate/threatening'.
                  harassment:
                    type: number
                    description: The score for the category 'harassment'.
                  harassment/threatening:
                    type: number
                    description: The score for the category 'harassment/threatening'.
                  illicit:
                    type: number
                    description: The score for the category 'illicit'.
                  illicit/violent:
                    type: number
                    description: The score for the category 'illicit/violent'.
                  self-harm:
                    type: number
                    description: The score for the category 'self-harm'.
                  self-harm/intent:
                    type: number
                    description: The score for the category 'self-harm/intent'.
                  self-harm/instructions:
                    type: number
                    description: The score for the category 'self-harm/instructions'.
                  sexual:
                    type: number
                    description: The score for the category 'sexual'.
                  sexual/minors:
                    type: number
                    description: The score for the category 'sexual/minors'.
                  violence:
                    type: number
                    description: The score for the category 'violence'.
                  violence/graphic:
                    type: number
                    description: The score for the category 'violence/graphic'.
                required:
                  - hate
                  - hate/threatening
                  - harassment
                  - harassment/threatening
                  - illicit
                  - illicit/violent
                  - self-harm
                  - self-harm/intent
                  - self-harm/instructions
                  - sexual
                  - sexual/minors
                  - violence
                  - violence/graphic
              category_applied_input_types:
                type: object
                description: >-
                  A list of the categories along with the input type(s) that the
                  score applies to.
                properties:
                  hate:
                    type: array
                    description: The applied input type(s) for the category 'hate'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  hate/threatening:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'hate/threatening'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  harassment:
                    type: array
                    description: The applied input type(s) for the category 'harassment'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  harassment/threatening:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'harassment/threatening'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  illicit:
                    type: array
                    description: The applied input type(s) for the category 'illicit'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  illicit/violent:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'illicit/violent'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  self-harm:
                    type: array
                    description: The applied input type(s) for the category 'self-harm'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                  self-harm/intent:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'self-harm/intent'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                  self-harm/instructions:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'self-harm/instructions'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                  sexual:
                    type: array
                    description: The applied input type(s) for the category 'sexual'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                  sexual/minors:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'sexual/minors'.
                    items:
                      type: string
                      enum:
                        - text
                      x-stainless-const: true
                  violence:
                    type: array
                    description: The applied input type(s) for the category 'violence'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                  violence/graphic:
                    type: array
                    description: >-
                      The applied input type(s) for the category
                      'violence/graphic'.
                    items:
                      type: string
                      enum:
                        - text
                        - image
                required:
                  - hate
                  - hate/threatening
                  - harassment
                  - harassment/threatening
                  - illicit
                  - illicit/violent
                  - self-harm
                  - self-harm/intent
                  - self-harm/instructions
                  - sexual
                  - sexual/minors
                  - violence
                  - violence/graphic
            required:
              - flagged
              - categories
              - category_scores
              - category_applied_input_types
      required:
        - id
        - model
        - results
      x-oaiMeta:
        name: The moderation object
        example: |
          {
            "id": "modr-0d9740456c391e43c445bf0f010940c7",
            "model": "omni-moderation-latest",
            "results": [
              {
                "flagged": true,
                "categories": {
                  "harassment": true,
                  "harassment/threatening": true,
                  "sexual": false,
                  "hate": false,
                  "hate/threatening": false,
                  "illicit": false,
                  "illicit/violent": false,
                  "self-harm/intent": false,
                  "self-harm/instructions": false,
                  "self-harm": false,
                  "sexual/minors": false,
                  "violence": true,
                  "violence/graphic": true
                },
                "category_scores": {
                  "harassment": 0.8189693396524255,
                  "harassment/threatening": 0.804985420696006,
                  "sexual": 1.573112165348997e-6,
                  "hate": 0.007562942636942845,
                  "hate/threatening": 0.004208854591835476,
                  "illicit": 0.030535955153511665,
                  "illicit/violent": 0.008925306722380033,
                  "self-harm/intent": 0.00023023930975076432,
                  "self-harm/instructions": 0.0002293869201073356,
                  "self-harm": 0.012598046106750154,
                  "sexual/minors": 2.212566909570261e-8,
                  "violence": 0.9999992735124786,
                  "violence/graphic": 0.843064871157054
                },
                "category_applied_input_types": {
                  "harassment": [
                    "text"
                  ],
                  "harassment/threatening": [
                    "text"
                  ],
                  "sexual": [
                    "text",
                    "image"
                  ],
                  "hate": [
                    "text"
                  ],
                  "hate/threatening": [
                    "text"
                  ],
                  "illicit": [
                    "text"
                  ],
                  "illicit/violent": [
                    "text"
                  ],
                  "self-harm/intent": [
                    "text",
                    "image"
                  ],
                  "self-harm/instructions": [
                    "text",
                    "image"
                  ],
                  "self-harm": [
                    "text",
                    "image"
                  ],
                  "sexual/minors": [
                    "text"
                  ],
                  "violence": [
                    "text",
                    "image"
                  ],
                  "violence/graphic": [
                    "text",
                    "image"
                  ]
                }
              }
            ]
          }
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````