查询任务详情
最近更新: 2026-10-22
返回任务的当前状态。创建任务后,用任务 ID 查询,直到 status 变为 "succeeded" 或 "failed"。
请求
GET https://api.nsfwcheckapi.com/v1/predictions/{id}
Path Params
idstring必填创建任务时返回的任务 ID。
- 示例:
- 0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70
Header Params
Authorizationstring必填Bearer 加创建该任务的账户下任意有效 API Key。
- 示例:
- Bearer sk_…
响应
| 状态码 | 含义 |
|---|---|
200 | 任务的当前状态,与创建时返回的对象相同(字段说明)。查询不扣积分。 |
401 | invalid_api_key:Key 缺失、格式错误或已撤销。 |
404 | prediction_not_found:该账户下没有这个任务。 |
429 | rate_limited:按 Retry-After 的秒数等待后再查询。 |
503 | temporarily_unavailable:稍后再查询。 |
任务状态
status | 最终状态 | 含义 | output | error |
|---|---|---|---|---|
waiting | 否 | 已受理,尚未开始 | null | null |
processing | 否 | 正在检测 | null | null |
succeeded | 是 | 结果已就绪 | object | null |
failed | 是 | 任务未能完成,积分已返还 | null | object |
任务提交后 10 分钟内未开始、或 20 分钟内未完成,会以 processing_timeout 失败。最终状态不会再变化,重复查询已结束的任务会返回相同的结果。
轮询
status为"waiting"或"processing"时每 1~2 秒查询一次,到"succeeded"或"failed"时停止。- 每个任务每秒最多查询 3 次,每个账户每秒最多 150 次。遇到
429时按Retry-After的秒数等待。 - 请保存任务 ID,它是读取结果的唯一方式;所有任务也会出现在你的任务历史中。
代码示例
请求
curl 'https://api.nsfwcheckapi.com/v1/predictions/0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70' \
-H 'Authorization: Bearer YOUR_API_KEY'
import requests
response = requests.get(
"https://api.nsfwcheckapi.com/v1/predictions/0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
task = response.json()
print(task["status"], task["output"])
const response = await fetch(
'https://api.nsfwcheckapi.com/v1/predictions/0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70',
{ headers: { Authorization: 'Bearer YOUR_API_KEY' } }
);
const task = await response.json();
console.log(task.status, task.output);
响应
200 OK,任务成功:
{
"id": "0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70",
"model": "general",
"status": "succeeded",
"policy": { "sensitivity": "standard" },
"model_version": "general-2026-08",
"output": {
"level": "L1",
"probabilities": { "L1": 0.94, "L2": 0.04, "L3": 0.01, "L4": 0.01 },
"is_nsfw": false
},
"error": null,
"created_at": "2026-10-22T08:30:00.000Z",
"started_at": "2026-10-22T08:30:00.412Z",
"completed_at": "2026-10-22T08:30:01.268Z",
"urls": {
"get": "https://api.nsfwcheckapi.com/v1/predictions/0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70"
}
}
200 OK,任务失败:
{
"id": "0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70",
"model": "general",
"status": "failed",
"policy": { "sensitivity": "standard" },
"model_version": null,
"output": null,
"error": {
"code": "invalid_image",
"message": "The image or its URL could not be processed."
},
"created_at": "2026-10-22T08:30:00.000Z",
"started_at": "2026-10-22T08:30:00.412Z",
"completed_at": "2026-10-22T08:30:00.903Z",
"urls": {
"get": "https://api.nsfwcheckapi.com/v1/predictions/0f8e3c52-6d1a-4b7e-9c2f-5a1b3d4e6f70"
}
}