> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a moderation

> Use CometAPI POST /v1/moderations to check text or multimodal input with an OpenAI-compatible moderation request.

Use this endpoint to check user-generated content before you send it to a model endpoint. Send an OpenAI-compatible moderation request with a `model` and an `input` value.

<Note>
  Use a CometAPI API key in the bearer header: `Authorization: Bearer $COMETAPI_KEY`.
</Note>

## Request body

| Field   | Type            | Required | Description                                                                                                                                                       |
| ------- | --------------- | -------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input` | string or array |      Yes | The content to check. Use a string for one text input, an array of strings for batch text checks, or OpenAI-style multimodal parts such as text plus `image_url`. |
| `model` | string          |      Yes | Moderation model ID. Use `omni-moderation-latest` for text and image moderation unless you have a specific moderation model requirement.                          |

For multimodal moderation, send OpenAI-style multimodal input with a model that supports it, such as `omni-moderation-latest`. Public image URLs must be downloadable by CometAPI servers. For a copyable image test, use a base64 data URL.

## Request examples

Send a single text string when you only need to classify one text input:

```bash theme={null}
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -d '{
    "model": "omni-moderation-latest",
    "input": "I want to bake cookies for my family."
  }'
```

Send an array of strings when you want to check multiple text inputs in one request:

```bash theme={null}
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      "I want to bake cookies.",
      "I want to kill someone."
    ]
  }'
```

Send text plus an image URL when your moderation input includes an image that CometAPI can download:

```bash theme={null}
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      { "type": "text", "text": "...text to classify goes here..." },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://www.gstatic.com/webp/gallery/1.png"
        }
      }
    ]
  }'
```

Use a base64 data URL when you need a self-contained image request:

```bash theme={null}
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      { "type": "text", "text": "...text to classify goes here..." },
      {
        "type": "image_url",
        "image_url": {
          "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"
        }
      }
    ]
  }'
```

## Response shape

The response includes `id`, `model`, `results`, and `usage`. Each item in `results` reports whether the matching input was flagged, category booleans, category scores, and input types applied to each category. For a batch text request, `results` contains one item per input string. Use `usage` for billing and monitoring fields.


## OpenAPI

````yaml api/openapi/content-moderation/create-moderation.openapi.json POST /v1/moderations
openapi: 3.1.0
info:
  title: Create Moderation
  version: 1.0.0
  description: Check content with CometAPI's OpenAI-compatible moderation endpoint.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/moderations:
    post:
      summary: Create a moderation
      description: >-
        Checks text or multimodal input with a moderation model. The response is
        OpenAI-compatible and returns one `results` item for each moderated
        input.
      operationId: createModeration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: >-
                    Required moderation model ID. Use `omni-moderation-latest`
                    for text and image moderation unless you have a specific
                    moderation model requirement.
                  example: omni-moderation-latest
                input:
                  description: >-
                    Content to check. Use a string for one text input, an array
                    of strings for batch text checks, or OpenAI-style multimodal
                    parts such as text plus `image_url` when the selected model
                    supports it.
                  oneOf:
                    - type: string
                      description: One text input to classify.
                      example: ...text to classify goes here...
                    - type: array
                      description: Batch text inputs to classify in one request.
                      items:
                        type: string
                      example:
                        - First text to classify.
                        - Second text to classify.
                    - type: array
                      description: >-
                        OpenAI-style multimodal input parts. Use a text part
                        with an image_url part for image moderation. Public
                        image URLs must be downloadable by CometAPI servers; use
                        a base64 data URL for a self-contained image request.
                      items:
                        oneOf:
                          - type: object
                            required:
                              - type
                              - text
                            properties:
                              type:
                                type: string
                                enum:
                                  - text
                                description: Text input part.
                              text:
                                type: string
                                description: Text to classify.
                            additionalProperties: false
                          - type: object
                            required:
                              - type
                              - image_url
                            properties:
                              type:
                                type: string
                                enum:
                                  - image_url
                                description: Image input part.
                              image_url:
                                type: object
                                required:
                                  - url
                                properties:
                                  url:
                                    type: string
                                    description: >-
                                      Publicly downloadable image URL or base64
                                      data URL.
                                additionalProperties: true
                                description: >-
                                  Image container for image input. Provide `url`
                                  with an HTTPS URL or a base64 data URL.
                            additionalProperties: false
                      example:
                        - type: text
                          text: ...text to classify goes here...
                        - type: image_url
                          image_url:
                            url: https://www.gstatic.com/webp/gallery/1.png
                  example: I want to check this text before sending it to a model.
            examples:
              Text:
                summary: Text input
                value:
                  model: omni-moderation-latest
                  input: I want to bake cookies for my family.
              Batch text:
                summary: Batch text input
                value:
                  model: omni-moderation-latest
                  input:
                    - I want to bake cookies.
                    - Plan a birthday party for my friend.
              Image URL:
                summary: Text plus image URL
                description: Use an image URL that CometAPI servers can download.
                value:
                  model: omni-moderation-latest
                  input:
                    - type: text
                      text: ...text to classify goes here...
                    - type: image_url
                      image_url:
                        url: https://www.gstatic.com/webp/gallery/1.png
              Image data URL:
                summary: Text plus image data URL
                description: Use a base64 data URL for a self-contained image request.
                value:
                  model: omni-moderation-latest
                  input:
                    - type: text
                      text: ...text to classify goes here...
                    - type: image_url
                      image_url:
                        url: >-
                          data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC
      responses:
        '200':
          description: Moderation decisions and token usage.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateModerationResponse'
              example:
                id: modr-1594
                model: omni-moderation-latest
                results:
                  - flagged: false
                    categories:
                      harassment: false
                      harassment/threatening: false
                      hate: false
                      hate/threatening: false
                      illicit: false
                      illicit/violent: false
                      self-harm: false
                      self-harm/intent: false
                      self-harm/instructions: false
                      sexual: false
                      sexual/minors: false
                      violence: false
                      violence/graphic: false
                    category_scores:
                      harassment: 0.0001
                      harassment/threatening: 0.0001
                      hate: 0.0001
                      hate/threatening: 0.0001
                      illicit: 0.0001
                      illicit/violent: 0.0001
                      self-harm: 0.0001
                      self-harm/intent: 0.0001
                      self-harm/instructions: 0.0001
                      sexual: 0.0001
                      sexual/minors: 0.0001
                      violence: 0.0001
                      violence/graphic: 0.0001
                    category_applied_input_types:
                      harassment:
                        - text
                      harassment/threatening:
                        - text
                      hate:
                        - text
                      hate/threatening:
                        - text
                      illicit:
                        - text
                      illicit/violent:
                        - text
                      self-harm:
                        - text
                      self-harm/intent:
                        - text
                      self-harm/instructions:
                        - text
                      sexual:
                        - text
                      sexual/minors:
                        - text
                      violence:
                        - text
                      violence/graphic:
                        - text
                usage:
                  prompt_tokens: 12
                  completion_tokens: 0
                  total_tokens: 12
                  input_tokens: 12
                  output_tokens: 0
                  prompt_tokens_details:
                    cached_tokens: 0
                  completion_tokens_details:
                    reasoning_tokens: 0
                  input_tokens_details: null
                  claude_cache_creation_1_h_tokens: 0
                  claude_cache_creation_5_m_tokens: 0
        '400':
          description: The request body is invalid or missing required input.
        '401':
          description: The API key is missing or invalid.
        '503':
          description: >-
            The selected moderation model is unavailable for the current
            account.
      x-codeSamples:
        - lang: Shell
          label: Text
          source: |
            curl https://api.cometapi.com/v1/moderations \
              -X POST \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "omni-moderation-latest",
              "input": "I want to bake cookies for my family."
            }'
        - lang: Shell
          label: Batch text
          source: |
            curl https://api.cometapi.com/v1/moderations \
              -X POST \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "omni-moderation-latest",
              "input": [
                "I want to bake cookies.",
                "I want to kill someone."
              ]
            }'
        - lang: Shell
          label: Image URL
          source: |
            curl https://api.cometapi.com/v1/moderations \
              -X POST \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "omni-moderation-latest",
              "input": [
                {
                  "type": "text",
                  "text": "...text to classify goes here..."
                },
                {
                  "type": "image_url",
                  "image_url": {
                    "url": "https://www.gstatic.com/webp/gallery/1.png"
                  }
                }
              ]
            }'
        - lang: Shell
          label: Image data URL
          source: |
            curl https://api.cometapi.com/v1/moderations \
              -X POST \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "omni-moderation-latest",
              "input": [
                {
                  "type": "text",
                  "text": "...text to classify goes here..."
                },
                {
                  "type": "image_url",
                  "image_url": {
                    "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"
                  }
                }
              ]
            }'
        - lang: Python
          label: Text
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.moderations.create(
                model="omni-moderation-latest",
                input="I want to bake cookies for my family.",
            )

            print(response)
        - lang: Python
          label: Image data URL
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.moderations.create(
                model="omni-moderation-latest",
                input=[
                    {"type": "text", "text": "...text to classify goes here..."},
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
                        },
                    },
                ],
            )

            print(response)
        - lang: Python
          label: Batch text
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.moderations.create(
                model="omni-moderation-latest",
                input=[
                    "I want to bake cookies.",
                    "I want to kill someone.",
                ],
            )

            for result in response.results:
                print(result.flagged)
        - lang: Python
          label: Image URL
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.moderations.create(
                model="omni-moderation-latest",
                input=[
                    {"type": "text", "text": "...text to classify goes here..."},
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "https://www.gstatic.com/webp/gallery/1.png",
                        },
                    },
                ],
            )

            print(response)
        - lang: JavaScript
          label: Text
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
              baseURL: "https://api.cometapi.com/v1",
              apiKey: process.env.COMETAPI_KEY,
            });

            const response = await client.moderations.create({
              model: "omni-moderation-latest",
              input: "I want to bake cookies for my family.",
            });

            console.log(response);
        - lang: JavaScript
          label: Image data URL
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
              baseURL: "https://api.cometapi.com/v1",
              apiKey: process.env.COMETAPI_KEY,
            });

            const response = await client.moderations.create({
              model: "omni-moderation-latest",
              input: [
                { type: "text", text: "...text to classify goes here..." },
                {
                  type: "image_url",
                  image_url: {
                    url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC",
                  },
                },
              ],
            });

            console.log(response);
        - lang: JavaScript
          label: Batch text
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
              baseURL: "https://api.cometapi.com/v1",
              apiKey: process.env.COMETAPI_KEY,
            });

            const response = await client.moderations.create({
              model: "omni-moderation-latest",
              input: [
                "I want to bake cookies.",
                "I want to kill someone.",
              ],
            });

            for (const result of response.results) {
              console.log(result.flagged);
            }
        - lang: JavaScript
          label: Image URL
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
              baseURL: "https://api.cometapi.com/v1",
              apiKey: process.env.COMETAPI_KEY,
            });

            const response = await client.moderations.create({
              model: "omni-moderation-latest",
              input: [
                { type: "text", text: "...text to classify goes here..." },
                {
                  type: "image_url",
                  image_url: {
                    url: "https://www.gstatic.com/webp/gallery/1.png",
                  },
                },
              ],
            });

            console.log(response);
components:
  schemas:
    CreateModerationResponse:
      type: object
      required:
        - id
        - model
        - results
        - usage
      properties:
        id:
          type: string
          description: Moderation request ID.
          example: modr-1594
        model:
          type: string
          description: Model used for moderation.
          example: omni-moderation-latest
        results:
          type: array
          description: >-
            Moderation decisions. For batch text input, this array contains one
            result per input string.
          items:
            $ref: '#/components/schemas/ModerationResult'
        usage:
          $ref: '#/components/schemas/ModerationUsage'
          description: Token usage for the moderation request.
      additionalProperties: true
    ModerationResult:
      type: object
      required:
        - flagged
        - categories
        - category_scores
        - category_applied_input_types
      properties:
        flagged:
          type: boolean
          description: Whether this input item was flagged by any moderation category.
          example: false
        categories:
          $ref: '#/components/schemas/ModerationCategories'
          description: Per-category boolean decision flags.
        category_scores:
          $ref: '#/components/schemas/ModerationCategoryScores'
          description: Per-category confidence scores between 0 and 1.
        category_applied_input_types:
          $ref: '#/components/schemas/ModerationCategoryAppliedInputTypes'
          description: >-
            For each category, the input types (`text`, `image`) that
            contributed to the decision.
      additionalProperties: true
    ModerationUsage:
      type: object
      description: >-
        Token usage for the moderation request. Additional provider accounting
        fields can be present.
      additionalProperties: true
      properties:
        prompt_tokens:
          type: integer
          description: Input tokens counted for the request.
          example: 12
        completion_tokens:
          type: integer
          description: Output tokens counted for the request.
          example: 0
        total_tokens:
          type: integer
          description: Total tokens counted for the request.
          example: 12
        input_tokens:
          type: integer
          description: Input token count when reported separately.
          example: 12
        output_tokens:
          type: integer
          description: Output token count when reported separately.
          example: 0
        prompt_tokens_details:
          type:
            - object
            - 'null'
          description: Detailed prompt token accounting when provided.
          additionalProperties: true
        completion_tokens_details:
          type:
            - object
            - 'null'
          description: Detailed completion token accounting when provided.
          additionalProperties: true
        input_tokens_details:
          type:
            - object
            - 'null'
          description: Detailed input token accounting when provided.
          additionalProperties: true
        claude_cache_creation_1_h_tokens:
          type: integer
          description: >-
            One-hour cache creation tokens when reported by the provider
            accounting layer.
          example: 0
        claude_cache_creation_5_m_tokens:
          type: integer
          description: >-
            Five-minute cache creation tokens when reported by the provider
            accounting layer.
          example: 0
    ModerationCategories:
      type: object
      description: Boolean moderation category decisions for one input item.
      additionalProperties: false
      properties:
        harassment:
          type: boolean
          description: Whether the input matched the harassment moderation category.
          example: false
        harassment/threatening:
          type: boolean
          description: >-
            Whether the input matched the harassment/threatening moderation
            category.
          example: false
        hate:
          type: boolean
          description: Whether the input matched the hate moderation category.
          example: false
        hate/threatening:
          type: boolean
          description: Whether the input matched the hate/threatening moderation category.
          example: false
        illicit:
          type: boolean
          description: Whether the input matched the illicit moderation category.
          example: false
        illicit/violent:
          type: boolean
          description: Whether the input matched the illicit/violent moderation category.
          example: false
        self-harm:
          type: boolean
          description: Whether the input matched the self-harm moderation category.
          example: false
        self-harm/intent:
          type: boolean
          description: Whether the input matched the self-harm/intent moderation category.
          example: false
        self-harm/instructions:
          type: boolean
          description: >-
            Whether the input matched the self-harm/instructions moderation
            category.
          example: false
        sexual:
          type: boolean
          description: Whether the input matched the sexual moderation category.
          example: false
        sexual/minors:
          type: boolean
          description: Whether the input matched the sexual/minors moderation category.
          example: false
        violence:
          type: boolean
          description: Whether the input matched the violence moderation category.
          example: false
        violence/graphic:
          type: boolean
          description: Whether the input matched the violence/graphic moderation category.
          example: false
    ModerationCategoryScores:
      type: object
      description: Moderation category confidence scores for one input item.
      additionalProperties: false
      properties:
        harassment:
          type: number
          format: float
          description: Confidence score for the harassment moderation category.
          example: 0.0001
        harassment/threatening:
          type: number
          format: float
          description: Confidence score for the harassment/threatening moderation category.
          example: 0.0001
        hate:
          type: number
          format: float
          description: Confidence score for the hate moderation category.
          example: 0.0001
        hate/threatening:
          type: number
          format: float
          description: Confidence score for the hate/threatening moderation category.
          example: 0.0001
        illicit:
          type: number
          format: float
          description: Confidence score for the illicit moderation category.
          example: 0.0001
        illicit/violent:
          type: number
          format: float
          description: Confidence score for the illicit/violent moderation category.
          example: 0.0001
        self-harm:
          type: number
          format: float
          description: Confidence score for the self-harm moderation category.
          example: 0.0001
        self-harm/intent:
          type: number
          format: float
          description: Confidence score for the self-harm/intent moderation category.
          example: 0.0001
        self-harm/instructions:
          type: number
          format: float
          description: Confidence score for the self-harm/instructions moderation category.
          example: 0.0001
        sexual:
          type: number
          format: float
          description: Confidence score for the sexual moderation category.
          example: 0.0001
        sexual/minors:
          type: number
          format: float
          description: Confidence score for the sexual/minors moderation category.
          example: 0.0001
        violence:
          type: number
          format: float
          description: Confidence score for the violence moderation category.
          example: 0.0001
        violence/graphic:
          type: number
          format: float
          description: Confidence score for the violence/graphic moderation category.
          example: 0.0001
    ModerationCategoryAppliedInputTypes:
      type: object
      description: Input part types considered for each moderation category.
      additionalProperties:
        type: array
        items:
          type: string
      properties:
        harassment:
          type: array
          description: Input part types that were evaluated for the harassment category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        harassment/threatening:
          type: array
          description: >-
            Input part types that were evaluated for the harassment/threatening
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        hate:
          type: array
          description: Input part types that were evaluated for the hate category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        hate/threatening:
          type: array
          description: >-
            Input part types that were evaluated for the hate/threatening
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        illicit:
          type: array
          description: Input part types that were evaluated for the illicit category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        illicit/violent:
          type: array
          description: >-
            Input part types that were evaluated for the illicit/violent
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        self-harm:
          type: array
          description: Input part types that were evaluated for the self-harm category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        self-harm/intent:
          type: array
          description: >-
            Input part types that were evaluated for the self-harm/intent
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        self-harm/instructions:
          type: array
          description: >-
            Input part types that were evaluated for the self-harm/instructions
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        sexual:
          type: array
          description: Input part types that were evaluated for the sexual category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        sexual/minors:
          type: array
          description: Input part types that were evaluated for the sexual/minors category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        violence:
          type: array
          description: Input part types that were evaluated for the violence category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
        violence/graphic:
          type: array
          description: >-
            Input part types that were evaluated for the violence/graphic
            category.
          items:
            type: string
            enum:
              - text
              - image
          example:
            - text
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: CometAPI API key
      description: >-
        CometAPI API key used for model requests. Send it as `Authorization:
        Bearer $COMETAPI_KEY`.

````