内容审核
判断文本/图片是否违反安全策略,供内容风控使用,返回分类标签与置信度。
请求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-你的令牌" \
-d '{
"model": "omni-moderation-latest",
"input": "待审核的文本内容"
}'
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
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 表示需要拦截
备注
审核接口免费或低价(取决于渠道配置),可在用户输入与模型输出两侧调用,形成双向风控。