內容審核
判斷文字/圖片是否違反安全政策,供內容風控使用,回傳分類旗標與信心分數。
请求REQUEST
POST
https://test.kailin.com.cn/v1/moderations响应RESPONSE
填写参数并发送请求,响应会显示在这里
請求
curl https://test.kailin.com.cn/v1/moderations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "omni-moderation-latest",
"input": "text to review"
}'
請求主體參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 否 | 預設 omni-moderation-latest,支援多模態輸入 |
input | string / array | 是 | 待審核文字;多模態時傳內容陣列 |
多模態輸入(文字 + 圖片):
{
"model": "omni-moderation-latest",
"input": [
{ "type": "moderation_text", "text": "some text" },
{ "type": "moderation_image", "image_url": "https://example.com/img.jpg" }
]
}
回應
{
"id": "modr-abc123",
"model": "omni-moderation-latest",
"results": [
{
"flagged": false,
"categories": {
"harassment": false,
"hate": false,
"sexual": false,
"violence": false
},
"category_scores": {
"harassment": 0.0001,
"hate": 0.0001,
"sexual": 0.0002,
"violence": 0.0003
}
}
]
}
| 欄位 | 說明 |
|---|---|
results[].flagged | 內容是否命中政策 |
results[].categories | 各分類的布林結果(還有 harassment_threatening、self-harm 等更多分類) |
results[].category_scores | 各分類的信心分數 0–1 |
典型用法
def check(text: str) -> bool:
resp = client.moderations.create(model="omni-moderation-latest", input=text)
return resp.results[0].flagged # True means the content should be blocked
備註
審核 API 免費或低價(取決於渠道),可在使用者輸入與模型輸出兩側都呼叫,形成雙向風控。