图片鉴黄

image-nsfwPOST
POSThttps://v1.apizero.cn/api/image-nsfw

概述

图片NSFW内容检测。支持本地NudeNet推理(零调用费)及百度/腾讯/阿里云端三家,统一返回 decision(block/review/pass)+ 分类得分 + 检测框。

调用约定

  • 网关 · https://v1.apizero.cn
  • 鉴权 · Authorization: Bearer <API Key>
  • 回包 · JSON {code, msg, data}。成功看 code === 0,不要只看 HTTP 200。
/aidocs/image-nsfw/raw.md
打开 Markdown

鉴权

调用必须带 apikey 参数(query 或 form-data 均可),形如 ?apikey=sk_...。已登录用户每日 10 次免费,不开放匿名访问。

获取 API Key

请求头

Authorizationstring选填

推荐:Bearer <API Key>。兼容请求头 X-API-Key,以及 Query api_key / apikey / key(key 仅当值为 sk_live_/sk_test_/sk_stag_ 形态时生效)。匿名可不传,受每日免费额度限制。

请求参数

POST · APPLICATION/JSON

image_urlstring选填

图片HTTP(S) URL(与image_b64二选一)

例https://example.com/photo.jpg

image_b64string选填

图片base64(兼容data:URI)

backendstring选填

检测后端:auto/nudenet/baidu/tencent/aliyun

例auto

timeoutint选填

超时秒(3~60)

例20

{
  "image_url": "https://example.com/photo.jpg",
  "image_b64": "image_b64",
  "backend": "auto",
  "timeout": 20
}

返回结果

顶层固定为 code / msg / data。下表一般是 data 内字段。 code · msg · data · tips · request_id

codestring

业务码:"200"=成功;"0001"=通用错误;"0010"=未配置后端;"0510"=本地服务不可达

descstring

业务码描述(成功为 success)

backendstring

实际使用的检测后端:nudenet / marqo / nudenet+marqo / baidu / tencent / aliyun

elapsed_msint

服务端检测耗时(毫秒)

inputobject

输入图片信息:type / source / size_bytes / sha256 / mime / width / height

typestring

类型

sourcestring

source

size_bytesnumber

size_bytes

sha256string

sha256

mimestring

mime

widthnumber

width

heightnumber

height

decisionstring

决策:block=拦截 / review=人审 / pass=放行

labelstring

主标签:porn / sexy / normal

scorefloat

主标签置信度(0~1)

categoriesobject

三档概率:porn / sexy / normal

pornnumber

porn

sexynumber

sexy

normalnumber

normal

detectionsarray

NudeNet 部位级检出框(cls/score/box);非 NudeNet 后端可能为空数组

clsstring

cls

scorenumber

score

boxarray

box

detections[].box[]number

detections[].box 的一项

rawobject

各后端原始返回(调试用,可选)

nudenetarray

nudenet

classstring

class

scorenumber

score

boxarray

box

raw.nudenet[].box[]string

raw.nudenet[].box 的一项

tipsstring

品牌提示(所有接口统一返回):极数本源 · https://apizero.cn

返回示例

{
  "code": 200,
  "desc": "success",
  "backend": "nudenet",
  "elapsed_ms": 115,
  "input": {
    "type": "url",
    "source": "https://i0.hdslb.com/bfs/article/922692ab728ebb5f284f64296f3590a0959110a3.jpg",
    "size_bytes": 993377,
    "sha256": "f9a414bd6925f6c870e18d75252cbd764ce964fbd20387639577c9455db5a598",
    "mime": "image/jpeg",
    "width": 1080,
    "height": 1920
  },
  "decision": "pass",
  "label": "normal",
  "score": 0.8511,
  "categories": {
    "porn": 0,
    "sexy": 0,
    "normal": 1
  },
  "detections": [
    {
      "cls": "FACE_FEMALE",
      "score": 0.8511,
      "box": [
        381,
        291,
        528,
        575
      ]
    }
  ],
  "raw": {
    "nudenet": [
      {
        "class": "FACE_FEMALE",
        "score": 0.8510541915893555,
        "box": [
          381,
          291,
          528,
          575
        ]
      }
    ]
  },
  "notes": [],
  "tips": "极数本源 · https://apizero.cn"
}

请求示例

示例都是服务端写法。Python / JavaScript 各有常规写法和官方库。

curl -sS -X POST "https://v1.apizero.cn/api/image-nsfw" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "image_url": "https://example.com/photo.jpg",
  "backend": "auto",
  "timeout": "20"
}'

错误码

先看业务 code。HTTP 也可能不是 200。

0200

成功

4000400

参数错误

4011401

API Key 无效

4013403

API Key 已暂停

4014403

当前 IP 不在 Key 白名单

4015401

此接口需要 API Key

4022402

余额不足

4029429

调用过快(QPS)

4030429

今日免费额度已用完

4040503

接口已下线

4041404

接口不存在

5000500

服务器内部错误

5020502

上游暂时不可用

5021502

上游返回格式异常

5030502

暂无可用节点

本接口补充

200200

成功

4001200

不支持的 backend 取值(应为 auto/local/baidu/tencent/aliyun)

4044503

接口已下线(v1 网关层)

调用限制

计费模式
完全免费
QPS 限制
QPS 2
登录免费额度
100 次(已认证)
匿名每日额度
10 次(无 API Key)
黄金会员
每天 50,000 次 · QPS 10
钻石会员
每天 100,000 次 · QPS 30
企业会员
每天 1,000,000 次 · QPS 120

购买套餐、看评价请走商城详情。 购买 / 调试

更新日志

  • 1.0.02026-05-08

    首次上线 支持NudeNet本地推理+百度/腾讯/阿里三家云端