Source: https://01router.com/zh/docs/moderations Base URL: https://01router.com/api/v1 # 内容审核 不生成任何内容,单独审核文本、图片和视频。返回一个总结果,以及每种类型各自的结果。文本和图片免费;含视频的请求每次 1 积分。 `POST /api/v1/moderations` 需要 Bearer API Key ## 结果与类别 每个结果都是 "none"(未审核:审核项被关闭、没有该类型内容,或审核失败)、true(通过)或 false(不通过)。任一类别分数 ≥ 0.5 即判为不通过。 类别:sexual(裸露或色情)、violence(血腥暴力)、minor_sexual(涉及可能未满 18 岁者的性内容)、real_person_sexual(可识别的真实人物被裸露、色情或侮辱性呈现)、prohibited(内容被直接拒绝,没有分数)。 超长文本只审核开头和结尾各 10,000 个字符。文件无法获取、过大、超过 10 分钟或不是 MP4/MOV 时返回 400 content_unreadable。 ## 生成和聊天里的 moderation 字段 生成接口(POST 和 GET /generations、回调)和非流式聊天也会返回 moderation 对象:result,以及 text、image、video,每类有自己的 result 和输入、输出检查。审核哪些输入和输出在项目里设置(默认全部开启);不带项目的调用按平台的全局设置;playground 始终全部审核。 输入被拦截时返回 400 content_policy_violation,不扣任何积分,错误体里带 moderation。输出被拦截时生成失败并退还积分。 流式聊天的输出不审核;响应头 X-Gateway-Moderation 给出输入的总结果。 ## 输入参数 | Field | Type | Required | Description | Constraints | | --- | --- | --- | --- | --- | | text | string \| string[] | no | 要审核的文本:一个字符串,或最多 20 个字符串(合并审核)。 | | | images | string[] | no | 最多 8 个图片 URL(https 或 data:image),单张不超过 8MB。 | | | videos | string[] | no | 最多 2 个视频 URL(https 或 data:video):MP4 或 MOV,单个不超过 20MB、10 分钟。 | | ## 输出字段 | Field | Type | Required | Description | Constraints | | --- | --- | --- | --- | --- | | id | string | — | mod_… | | | object | "moderation" | — | moderation | | | result | "none" \| true \| false | — | 总结果:任一类型不通过为 false;有内容通过为 true;什么都没审核为 "none"。 | | | text / image / video | object | — | 每种类型的结果:result("none" \| true \| false)、category(分数最高的不通过类别)、scores(各类别 0-1 的分数)、error(无法审核的原因)。 | | | credits | number | — | 扣除的积分:只有文本和图片为 0;含视频为 1(审核无法完成时退回)。 | | ## 使用说明 - 计费与限制:文本免费;图片免费,每个账号每天(UTC)最多 1,000 张;含视频的请求每次 1 积分(最多 2 个视频,不论几个),审核无法完成时退回。每个账号同时最多 5 个请求。超出限制返回 429 moderation_limit 并带 Retry-After 响应头;积分不足返回 402。 ## cURL ```bash curl 'https://01router.com/api/v1/moderations' \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "A golden retriever puppy playing in a sunny park", "images": [ "https://example.com/photo.jpg" ] }' ``` ## 200 · application/json ```json { "id": "mod_example", "object": "moderation", "result": false, "text": { "result": true, "scores": { "sexual": 0.0006, "violence": 0.0008, "minor_sexual": 0.0007, "real_person_sexual": 0.0008 } }, "image": { "result": false, "category": "violence", "scores": { "sexual": 0.012, "violence": 0.9817, "minor_sexual": 0.0007, "real_person_sexual": 0.0008 } }, "video": { "result": "none" }, "credits": 0 } ```