# 内容安全审核
**请求方式:** GET
**接口地址:** https://api.hk0.cc/api/moderation
**接口描述:** 内容安全审核接口,响应结构对齐腾讯云文本内容安全(TMS TextModeration),可直接复用腾讯云 SDK 的返回解析逻辑。
请求参数(兼容腾讯云字段名):
text 或 Content 必填,待检测文本,UTF-8,上限 20000 字符
BizType 可选,业务类型标识,默认 moderation,原样回传
DataId 可选,业务侧内容 ID,仅用于日志
engine 可选,hybrid(默认,规则+模型)、rules(仅词库,毫秒级)、llm(仅模型)
scene 可选,comment(默认)、nickname、profile、article
mode 可选,loose、normal(默认)、strict
categories 可选,逗号分隔:porn,politics,violence,ad,illegal,contact,url,misc
replace 可选,1 返回打码后的文本(Extra.filtered)
detail 可选,1 返回命中词原文,默认首字打码
fast 可选,1 等价于 engine=rules
返回字段(与腾讯云一致):
Response.RequestId 请求唯一 ID
Response.Label 结论:Normal 正常 / Porn 色情 / Ad 广告 / Illegal 违法 / Polity 政治 / Terror 暴恐
Response.SubLabel 细分标签,当前为空
Response.Suggestion 建议:Pass / Review / Block
Response.Score 风险分 0-100
Response.Keywords 命中关键词(默认打码)
Response.DetailResults 分库命中明细:Label、SubLabel、Suggestion、Keywords、Score、LibId、LibName
Response.SentimentAnalysis 情感分析,固定 Neutral
Response.BizType 原样回传
Response.Extra 扩展信息 JSON 字符串:verdict、action_text、risk_text、reason、suggestion、categories、hit_count、engine、llm、elapsed_ms、filtered
错误返回:Response.Error.Code / Response.Error.Message,HTTP 状态码 200,与腾讯云一致。
类别映射:porn→Porn,ad/contact/url→Ad,politics→Polity,violence→Terror,illegal/misc→Illegal。
性能:明确违规命中词库时约 1ms 返回;其余平均约 500ms;相同文本 10 分钟内命中缓存。
## 请求参数
| 参数名 | 可传值说明 | 传入位置 | 是否必填 | 示例值 | 默认值 | 参数说明 |
|--------|----------|----------|----------|--------|--------|----------|
| text | 这是一个测试文本 | query | 必传 | 加微信日赚500 | — | 必填,待检测文本,也可用腾讯云字段名 Content,URL 编码,UTF-8,上限 20000 字符 |
| engine | hybrid | query | 可选 | hybrid | hybrid | 可选,检测引擎:hybrid 规则+模型(默认)、rules 仅词库(毫秒级)、llm 仅大模型 |
| scene | comment | query | 可选 | comment | comment | 可选,使用场景:comment 评论(默认)、nickname 昵称、profile 简介、article 正文 |
| mode | normal | query | 可选 | normal | normal | 可选,阈值模式:loose 宽松、normal 标准(默认)、strict 严格 |
| categories | porn,ad | query | 可选 | porn,ad | — | 可选,只检测指定类别,逗号分隔:porn politics violence ad illegal contact url misc |
| replace | 0 | query | 可选 | 0 | 0 | 可选,传 1 时返回打码后的文本(filtered 字段) |
| detail | 0 | query | 可选 | 0 | 0 | 可选,传 1 时 hits 返回命中词原文,默认首字打码 |
| fast | 0 | query | 可选 | 0 | 0 | 可选,传 1 等价于 engine=rules,只走词库快筛 |
| BizType | moderation | query | 可选 | moderation | moderation | 可选,业务类型标识,默认 moderation,原样回传到 Response.BizType |
| DataId | | query | 可选 | — | — | 可选,业务侧内容 ID,仅用于日志 |
## 返回示例
```json
{
"Response": {
"RequestId": "f71ffd6ef11a8af1462b28601cd05855",
"Label": "Porn",
"SubLabel": "",
"Suggestion": "Block",
"Keywords": [
"约炮",
"加微信"
],
"Score": 100,
"DetailResults": [
{
"Label": "Porn",
"SubLabel": "",
"Suggestion": "Block",
"Keywords": [
"约炮"
],
"Score": 95,
"LibId": "porn",
"LibName": "色情低俗"
},
{
"Label": "Ad",
"SubLabel": "",
"Suggestion": "Block",
"Keywords": [
"加微信"
],
"Score": 45,
"LibId": "ad",
"LibName": "广告导流"
}
],
"SentimentAnalysis": {
"Label": "Neutral",
"Score": 0
},
"BizType": "moderation",
"Extra": "{"verdict":"违规","action":"block","action_text":"拦截","risk_level":"high","risk_text":"高风险","reason":"命中「色情低俗」类内容 2 处,建议拦截","suggestion":"拒绝发布","safe":false,"categories":[{"key":"porn","name":"色情低俗","count":1},{"key":"ad","name":"广告导流","count":1}],"hit_count":2,"scene":"comment","mode":"normal","engine":"rules","elapsed_ms":0.15,"llm":{"used":false,"error":"rules_confident"},"text_length":11,"filtered":"同城**,***选妹子"}"
}
}
```