文本审核(DFA)
POST
/api/v1/moderatePOST/api/moderation/check-text基于敏感词库的快速文本审核接口,采用 github.com/zmexing/go-sensitive-word DFA 算法(确定有限自动机),内存词库 + 内置词库(政治 / 色情 / 暴力 / 毒品 / 赌博 / 诈骗 / 辱骂 / 广告 / 疫情 / 反腐 / 民生),延迟 <1ms。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 必填 | 待审核文本 |
请求示例
bash
curl -X POST https://api.ogmiao.com/api/v1/moderate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{"text": "待审核内容"}'响应示例
JSON
{
"is_safe": false,
"violations": [
{
"type": "other",
"description": "命中敏感词库",
"confidence": 1.0,
"matched_text": "敏感词",
"start_offset": 3,
"end_offset": 6
}
],
"total_violations": 1,
"engine": "go-sensitive-word",
"algorithm": "DFA"
}说明:/api/moderation/check-text 与 /api/v1/moderate 等价,前者用于站内业务前置检测,后者对外暴露统一审核入口。