文本审核 API 接入文档text-censor
对文本进行多维度违规内容审核,覆盖政治敏感、谩骂、色情、违规广告、暴恐、低俗等类别,返回审核结论 + 命中违规词详情列表。 • 5000 字以内(中英文均按 1 字符计),单次请求审核 • 三态结论:合规(is_compliant=true)/ 不合规(is_compliant=false)/ 疑似(is_suspected=true,需人工复核) • 详细命中信息:每条违规含 category(类别)/ word(触发词)/ level(等级)/ msg(说明) • 衍生字段:violations(去重违规词数组)/ violation_categories(命中类别去重)/ violation_count(违规条数),前端可直接展示「触发 X 项违规:政治、谩骂…」 • 隐私保护:缓存 key 用 sha256 哈希,原文不进入 key;错误日志不记录文本内容
1. 基本信息
| 接口地址 | https://v1.apizero.cn/api/text-censor |
|---|---|
| 请求方法 | POST |
| 分类 | content |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 5 req/s |
| 每日免费额度 | 100 次(已认证用户) |
| 匿名每日额度 | 30 次(无 API Key) |
| VIP 免费 | 否 |
| 调用次数 |
2. 认证
匿名每日 30 次、QPS 2;登录用户每日 100 次、QPS 5(全部免费)。命中 1 小时缓存(按 sha256 文本哈希)不计入上游配额。
获取 API Key:登录 https://apizero.cn/account/keys
3. 请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
text | string | 是 | 待审核文本,1-5000 个字符(中英文均按 1 字符计) | 今天天气不错,适合出门散步。 |
4. 请求头
| Header | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
Authorization | string | 否 | API Key 鉴权头,格式 Bearer sk_live_xxx;匿名调用时可省略(每日 30 次免费) | Bearer sk_live_xxxxxxxxxxxxxx |
Content-Type | string | 否 | 支持 application/x-www-form-urlencoded 或 application/json | application/json |
5. 请求示例
以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。
cURL
curl -X POST "https://v1.apizero.cn/api/text-censor" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "今天天气不错,适合出门散步。"
}'Python
import requests
resp = requests.request(
"POST",
"https://v1.apizero.cn/api/text-censor",
headers={"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
json={
"text": "今天天气不错,适合出门散步。",
},
timeout=15,
)
resp.raise_for_status()
print(resp.json())JavaScript (Node.js)
// Node.js 18+ / 浏览器原生 fetch
const res = await fetch("https://v1.apizero.cn/api/text-censor", {
method: "POST",
headers: {
"X-Api-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"text": "今天天气不错,适合出门散步。"
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);Go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
body := []byte(`{"text":"今天天气不错,适合出门散步。"}`)
req, _ := http.NewRequest("POST", "https://v1.apizero.cn/api/text-censor", bytes.NewBuffer(body))
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}PHP
<?php
$payload = json_encode([
"text" => "今天天气不错,适合出门散步。",
], JSON_UNESCAPED_UNICODE);
$ch = curl_init("https://v1.apizero.cn/api/text-censor");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
"X-Api-Key: YOUR_API_KEY",
"Content-Type: application/json",
],
CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
print_r($data);6. 响应字段
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
text | string | 回传待审核的文本原文 | — |
text_length | number | 文本字符长度(mb_strlen,中英文均按 1 字符计) | — |
conclusion | string | 审核结论文字描述:合规 / 不合规 / 疑似 / 审核失败 | — |
conclusion_type | number | 审核结论数字编码:1=合规 / 2=不合规 / 3=疑似 / 4=审核失败 | — |
is_compliant | boolean | 便捷判断:是否完全合规(仅 conclusion_type=1 时为 true) | — |
is_suspected | boolean | 便捷判断:是否疑似违规(conclusion_type=3,建议人工复核) | — |
violation_count | number | 命中违规条数;合规时为 0 | — |
violation_categories | string[] | 命中违规类别列表(去重),如 ["政治","谩骂"];合规时为空数组 | — |
violations | string[] | 命中触发词列表(去重);合规时为空数组 | — |
details | object[] | 违规命中明细数组;合规时为空数组 | — |
details[].category | string | 违规类别,如 政治 / 谩骂 / 色情 / 违规广告 / 暴恐 / 低俗 | — |
details[].level | number? | 违规等级编号(上游分级,无明确取值标准,建议结合 category 使用) | — |
details[].word | string | 触发的具体词语 | — |
details[].msg | string | 违规详细说明,如「存在政治内容不合规」 | — |
7. 响应示例
{
"code": 0,
"msg": "成功",
"data": {
"text": "法轮功是邪教组织",
"text_length": 8,
"conclusion": "不合规",
"conclusion_type": 2,
"is_compliant": false,
"is_suspected": false,
"violation_count": 2,
"violation_categories": [
"政治"
],
"violations": [
"法轮功",
"邪教"
],
"details": [
{
"category": "政治",
"level": 3,
"word": "法轮功",
"msg": "存在政治内容不合规"
},
{
"category": "政治",
"level": 3,
"word": "邪教",
"msg": "存在政治内容不合规"
}
]
},
"request_id": "abc123def456"
}8. 错误码
| code | status | 说明 |
|---|---|---|
4000 | — | 参数错误:text 缺失/为空 / 超过 5000 字符上限 |
4015 | — | 匿名调用每日额度用完,需要 API Key |
4029 | — | QPS 超限 |
4030 | — | 今日额度用完 |
5020 | — | 上游 HTTP 失败 |
5021 | — | 上游响应格式异常 / 审核服务暂不可用 |
9. 变更日志
- 1.0.0(2026-05-07)
- 首次上线,对接 alapi.cn /api/censor/text 文本审核服务
- 支持 5000 字以内文本审核,覆盖政治/谩骂/色情/违规广告/暴恐/低俗等类别
- 修复源码字段映射错误:上游实际字段是 word/category/level/msg(而非 type/sub_type/words[])
- 新增便捷布尔字段 is_compliant / is_suspected,前端可直接 if 判断
- 新增聚合字段:violation_count(违规条数)/ violations(去重词列表)/ violation_categories(去重类别)
- 隐私保护:缓存 key 用 sha256 哈希原文,错误日志不记录文本内容
- 相同文本 1 小时缓存(同一表单/评论提交常重复审核)
- 支持 application/json 请求体(通过 v1 网关 mergeJsonBody 自动解析)
常见问题
文本审核 接口怎么免费使用?
未登录用户每个 IP 每天 30 次免费。登录用户创建 API Key 后每天 100 次免费,超额部分按点数计费(0 点/次)。
文本审核 支持哪些调用方式?
接口使用 POST 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。
调用不限额么? QPS 是多少?
本接口 QPS 限制 5 req/s,每个 API Key 每日免费 100 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。
这个接口跟自己直连上游有什么区别?
极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。