跳转到主要内容
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.

在将用户生成内容发送到模型端点之前,使用此端点进行检查。发送一个与 OpenAI 兼容的审核请求,其中包含 modelinput 值。
在 bearer 请求头中使用 CometAPI API key:Authorization: Bearer <COMETAPI_KEY>

请求体

FieldTypeRequiredDescription
inputstring or arrayYes要检查的内容。单条文本输入使用字符串,批量文本检查使用字符串数组,或者使用 OpenAI 风格的多模态部分,例如文本加上 image_url
modelstringYes审核 model ID。除非你有特定的审核模型要求,否则文本和图像审核请使用 omni-moderation-latest
对于多模态审核,请使用 OpenAI 风格的多模态 input,并搭配支持该能力的模型,例如 omni-moderation-latest。公开图片 URL 必须能够被 CometAPI 服务器下载。若要进行可复制的图片测试,请使用 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": "I want to bake cookies for my family."
  }'
当你想在一次请求中检查多条文本输入时,发送一个字符串数组:
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."
    ]
  }'
当你的审核 input 包含 CometAPI 可下载的图片时,发送文本加图片 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": "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"
        }
      }
    ]
  }'

响应结构

响应包含 idmodelresultsusageresults 中的每一项都会报告对应 input 是否被标记、类别布尔值、类别分数,以及应用于各类别的输入类型。对于批量文本请求,results 会为每个输入字符串包含一项。使用 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.