> ## 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.

# 모더레이션 생성

> CometAPI POST /v1/moderations를 사용해 OpenAI 호환 모더레이션 요청으로 텍스트 또는 멀티모달 입력을 검사합니다.

모델 엔드포인트로 보내기 전에 이 엔드포인트를 사용해 사용자 생성 콘텐츠를 검사하세요. `model`과 `input` 값을 포함한 OpenAI 호환 모더레이션 요청을 전송합니다.

<Note>
  bearer 헤더에 CometAPI API 키를 사용하세요: `Authorization: Bearer $COMETAPI_KEY`.
</Note>

## 요청 본문

| Field   | Type            | Required | Description                                                                                                        |
| ------- | --------------- | -------: | ------------------------------------------------------------------------------------------------------------------ |
| `input` | string or array |      Yes | 검사할 콘텐츠입니다. 하나의 텍스트 입력에는 문자열을 사용하고, 일괄 텍스트 검사에는 문자열 배열을 사용하거나, 텍스트와 `image_url` 같은 OpenAI 스타일 멀티모달 파트를 사용할 수 있습니다. |
| `model` | string          |      Yes | 모더레이션 model ID입니다. 특정 모더레이션 모델 요구 사항이 없다면 텍스트 및 이미지 모더레이션에는 `omni-moderation-latest`를 사용하세요.                       |

멀티모달 모더레이션의 경우 `omni-moderation-latest`처럼 이를 지원하는 모델과 함께 OpenAI 스타일 멀티모달 입력을 전송하세요. 공개 이미지 URL은 CometAPI 서버에서 다운로드할 수 있어야 합니다. 복사 가능한 이미지 테스트에는 base64 데이터 URL을 사용하세요.

## 요청 예시

하나의 텍스트 입력만 분류하면 되는 경우 단일 텍스트 문자열을 전송하세요:

```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."
  }'
```

하나의 요청에서 여러 텍스트 입력을 검사하려면 문자열 배열을 전송하세요:

```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."
    ]
  }'
```

CometAPI가 다운로드할 수 있는 이미지가 모더레이션 입력에 포함된 경우 텍스트와 이미지 URL을 함께 전송하세요:

```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"
        }
      }
    ]
  }'
```

자체 포함형 이미지 요청이 필요할 때는 base64 데이터 URL을 사용하세요:

```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"
        }
      }
    ]
  }'
```

## 응답 형태

응답에는 `id`, `model`, `results`, `usage`가 포함됩니다. `results`의 각 항목은 해당 입력이 플래그되었는지 여부, 카테고리 불리언 값, 카테고리 점수, 그리고 각 카테고리에 적용된 입력 유형을 보고합니다. 일괄 텍스트 요청의 경우 `results`에는 입력 문자열마다 하나의 항목이 포함됩니다. 청구 및 모니터링 필드에는 `usage`를 사용하세요.


## 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`.

````