敏感词检测
敏感词/违禁词检测,基于测罗API在线检测(涉政/涉黄/暴恐/广告违禁/极限词等),支持脱敏文本输出,本地词库降级
GET
https://api.tinyaii.cn/v1/sensitiveword
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| text | string | 必填 | 待检测文本 | 这是一段测试文本 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| text | string | 原始文本 |
| has_sensitive | bool | 是否包含敏感词 |
| matched_words | array | 匹配到的敏感词列表,每项含 word(敏感词)、source(分类)、start/end(位置) |
| masked_text | string | 脱敏文本(敏感词替换为**) |
| count | int | 匹配到的敏感词数量 |
| source | string | 出处 |
返回示例
{
"code": 200,
"message": "success",
"data": {
"text": "这是最好的产品,国家级认证",
"has_sensitive": true,
"matched_words": [
{
"word": "国家",
"start": 8,
"end": 10
},
{
"word": "最",
"start": 2,
"end": 3
}
],
"masked_text": "这**好的产品,**级认证",
"count": 2
}
}
调用示例
curl "https://api.tinyaii.cn/v1/sensitiveword?text=这是一段测试文本" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch("https://api.tinyaii.cn/v1/sensitiveword?text=这是一段测试文本", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());import requests
resp = requests.get(
"https://api.tinyaii.cn/v1/sensitiveword",
params={"text": "这是一段测试文本"},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=10,
)
print(resp.json())把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。