Перейти до основного вмісту
POST
/
v1
/
moderations
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."
}'
{
  "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
  }
}

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.

Використовуйте цей endpoint, щоб перевіряти контент, створений користувачами, перш ніж надсилати його до endpoint моделі. Надішліть OpenAI-сумісний moderation request із model та значенням input.
Використовуйте API key CometAPI у bearer header: Authorization: Bearer <COMETAPI_KEY>.

Тіло запиту

FieldTypeRequiredDescription
inputstring or arrayYesКонтент для перевірки. Використовуйте string для одного текстового input, масив рядків для пакетної перевірки тексту або multimodal parts у стилі OpenAI, як-от текст плюс image_url.
modelstringYesmodel ID moderation. Використовуйте omni-moderation-latest для moderation тексту та зображень, якщо у вас немає конкретної вимоги до moderation model.
Для multimodal moderation надсилайте multimodal input у стилі OpenAI з моделлю, яка це підтримує, наприклад omni-moderation-latest. Публічні URL зображень мають бути доступні для завантаження серверами CometAPI. Для тесту зображення, який можна легко скопіювати, використовуйте base64 data URL.

Приклади запитів

Надсилайте один текстовий рядок, якщо вам потрібно класифікувати лише один текстовий input:
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."
  }'
Надсилайте масив рядків, якщо хочете перевірити кілька текстових input в одному запиті:
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."
    ]
  }'
Надсилайте текст і URL зображення, якщо ваш input для moderation містить зображення, яке CometAPI може завантажити:
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 data URL, якщо вам потрібен самодостатній запит із зображенням:
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 повідомляє, чи було позначено відповідний input, булеві значення категорій, оцінки категорій і типи input, застосовані до кожної категорії. Для пакетного текстового запиту results містить один елемент на кожен рядок input. Використовуйте usage для полів білінгу та моніторингу.

Авторизації

Authorization
string
header
обов'язково

CometAPI API key used for model requests. Send it as Authorization: Bearer <COMETAPI_KEY>.

Тіло

application/json
model
string
обов'язково

Required moderation model ID. Use omni-moderation-latest for text and image moderation unless you have a specific moderation model requirement.

Приклад:

"omni-moderation-latest"

input
обов'язково

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.

Приклад:

"I want to check this text before sending it to a model."

Відповідь

Moderation decisions and token usage.

id
string
обов'язково

Moderation request ID.

Приклад:

"modr-1594"

model
string
обов'язково

Model used for moderation.

Приклад:

"omni-moderation-latest"

results
object[]
обов'язково

Moderation decisions. For batch text input, this array contains one result per input string.

usage
object
обов'язково

Token usage for the moderation request. Additional provider accounting fields can be present.