跳轉到主要內容
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 header 中使用 CometAPI API key:Authorization: Bearer <COMETAPI_KEY>

請求主體

欄位類型必填說明
inputstring 或 array要檢查的內容。單一文字輸入請使用字串,批次文字檢查請使用字串陣列,或使用 OpenAI 風格的多模態部分,例如文字加上 image_url
modelstring審查模型的 model ID。除非你有特定的審查模型需求,否則請使用 omni-moderation-latest 進行文字與圖片審查。
對於多模態審查,請使用支援該功能的模型傳送 OpenAI 風格的多模態輸入,例如 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."
    ]
  }'
當你的審查輸入包含 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 中的每個項目都會回報對應輸入是否被標記、各分類的布林值、分類分數,以及套用到各分類的輸入類型。對於批次文字請求,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.