正在启动平台

图片鉴黄 API 接入文档image-nsfw

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

1. 基本信息

接口地址https://v1.apizero.cn/api/image-nsfw
请求方法POST
分类ai
提供方极数本源
计费模式免费试用
单次消耗0 积分
起步价
QPS 限制2 req/s
每日免费额度100 次(已认证用户)
匿名每日额度10 次(无 API Key)
VIP 免费
调用次数

2. 认证

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

获取 API Key:登录 https://apizero.cn/account/keys

3. 请求参数

参数名类型必填说明示例
image_urlstring图片HTTP(S) URL(与image_b64二选一)https://example.com/photo.jpg
image_b64string图片base64(兼容data:URI)
backendstring检测后端:auto/nudenet/baidu/tencent/aliyunauto
timeoutint超时秒(3~60)

5. 请求示例

以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。

cURL

curl -X POST "https://v1.apizero.cn/api/image-nsfw" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "image_url": "https://example.com/photo.jpg",
  "image_b64": "<image_b64>",
  "backend": "auto",
  "timeout": ""
}'

Python

import requests

resp = requests.request(
    "POST",
    "https://v1.apizero.cn/api/image-nsfw",
    headers={"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
    json={
    "image_url": "https://example.com/photo.jpg",
    "image_b64": "<image_b64>",
    "backend": "auto",
    "timeout": "",
},
    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/image-nsfw", {
  method: "POST",
  headers: {
    "X-Api-Key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "image_url": "https://example.com/photo.jpg",
    "image_b64": "<image_b64>",
    "backend": "auto",
    "timeout": ""
  }),
});
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(`{"image_url":"https://example.com/photo.jpg","image_b64":"<image_b64>","backend":"auto","timeout":""}`)
	req, _ := http.NewRequest("POST", "https://v1.apizero.cn/api/image-nsfw", 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([
    "image_url" => "https://example.com/photo.jpg",
    "image_b64" => "<image_b64>",
    "backend" => "auto",
    "timeout" => "",
], JSON_UNESCAPED_UNICODE);

$ch = curl_init("https://v1.apizero.cn/api/image-nsfw");
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. 响应字段

字段类型说明示例
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
decisionstring决策:block=拦截 / review=人审 / pass=放行
labelstring主标签:porn / sexy / normal
scorefloat主标签置信度(0~1)
categoriesobject三档概率:porn / sexy / normal
detectionsarrayNudeNet 部位级检出框(cls/score/box);非 NudeNet 后端可能为空数组
rawobject各后端原始返回(调试用,可选)
tipsstring服务提示文案

7. 响应示例

{
  "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"
}

8. 错误码

codestatus说明
200成功
4000参数错误:必须提供 image_url 或 image_b64
4011后端凭证缺失:百度 / 腾讯 / 阿里 AK·SK 未提供
4001不支持的 backend 取值(应为 auto/local/baidu/tencent/aliyun)
4015API Key 缺失或非法(v1 网关层)
4044接口已下线(v1 网关层)
5020未配置任何后端:本地 server.py 未运行且未提供云端凭证
5021本地 server.py 不可达(连接被拒 / 超时 / 异常响应)

9. 变更日志

  • 1.0.0(2026-05-08)
    • 首次上线
    • 支持NudeNet本地推理+百度/腾讯/阿里三家云端

常见问题

图片鉴黄 接口怎么免费使用?

未登录用户每个 IP 每天 10 次免费。登录用户创建 API Key 后每天 100 次免费,超额部分按点数计费(0 点/次)。

图片鉴黄 支持哪些调用方式?

接口使用 POST 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。

调用不限额么? QPS 是多少?

本接口 QPS 限制 2 req/s,每个 API Key 每日免费 100 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。

这个接口跟自己直连上游有什么区别?

极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。