Getting started
Last updated: 2026-10-22
The NSFW Check API tells you how explicit an image is. It works asynchronously: you submit an image URL and get a task ID back at once, then query the task until its result is ready.
POST /v1/predictions → 201 Created status "waiting"
GET /v1/predictions/{id} → 200 OK status "processing" (query again)
GET /v1/predictions/{id} → 200 OK status "succeeded" + output
Basics
| Item | Value |
|---|---|
| Base URL | https://api.nsfwcheckapi.com |
| Authentication | Authorization: Bearer YOUR_API_KEY — see Authentication |
| Request body | JSON with Content-Type: application/json, at most 64 KiB |
| Responses | JSON (UTF-8), each with an X-Request-Id header |
| Times | ISO 8601 strings in UTC, for example 2026-10-22T08:30:00.000Z |
| Billing | 1 credit per accepted task; a task that finally fails returns its credit. Queries are free. See Pricing. |
Quickstart
1. Create an API key
Sign in and create a key under API keys. New accounts get free starter credits.
2. Submit a task
curl -X POST 'https://api.nsfwcheckapi.com/v1/predictions' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{ "input": { "image": "https://images.example.com/photo.jpg" } }'
The response returns at once with the task id and "status": "waiting".
3. Query the task until it is final
curl 'https://api.nsfwcheckapi.com/v1/predictions/TASK_ID' \
-H 'Authorization: Bearer YOUR_API_KEY'
Query every 1–2 seconds while status is "waiting" or "processing".
4. Read the result
When status is "succeeded":
output.level— the most probable level,L1(lowest risk) toL4(most explicit);output.probabilities— the probability of each level;output.is_nsfw— the verdict under your policy.
Every field is described in Image Moderation.
Complete example
Submit a task, poll it until it is final, then read the result.
import time
import uuid
import requests
API = "https://api.nsfwcheckapi.com"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
def check_image(image_url: str, sensitivity: str = "standard") -> dict:
# 1. Submit the task. Keep the idempotency key to retry safely.
response = requests.post(
f"{API}/v1/predictions",
headers={**HEADERS, "Idempotency-Key": uuid.uuid4().hex},
json={"input": {"image": image_url}, "policy": {"sensitivity": sensitivity}},
timeout=30,
)
response.raise_for_status()
task = response.json()
# 2. Poll until the task is final.
while task["status"] in ("waiting", "processing"):
time.sleep(1)
response = requests.get(task["urls"]["get"], headers=HEADERS, timeout=30)
if response.status_code == 429:
time.sleep(int(response.headers.get("Retry-After", "1")))
continue
response.raise_for_status()
task = response.json()
# 3. Read the result.
if task["status"] == "failed":
raise RuntimeError(task["error"]["code"])
return task["output"]
print(check_image("https://images.example.com/photo.jpg"))
const API = 'https://api.nsfwcheckapi.com';
const headers = { Authorization: 'Bearer YOUR_API_KEY' };
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function checkImage(imageUrl, sensitivity = 'standard') {
// 1. Submit the task. Keep the idempotency key to retry safely.
let response = await fetch(`${API}/v1/predictions`, {
method: 'POST',
headers: {
...headers,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({ input: { image: imageUrl }, policy: { sensitivity } }),
});
if (!response.ok) throw new Error(`Submit failed: ${response.status}`);
let task = await response.json();
// 2. Poll until the task is final.
while (task.status === 'waiting' || task.status === 'processing') {
await sleep(1000);
response = await fetch(task.urls.get, { headers });
if (response.status === 429) {
await sleep(Number(response.headers.get('Retry-After') ?? 1) * 1000);
continue;
}
if (!response.ok) throw new Error(`Query failed: ${response.status}`);
task = await response.json();
}
// 3. Read the result.
if (task.status === 'failed') throw new Error(task.error.code);
return task.output;
}
console.log(await checkImage('https://images.example.com/photo.jpg'));
Next steps
- Authentication — API keys and how to keep them safe.
- Image Moderation — every parameter and response field.
- Get task details — task statuses and polling.
- Errors and Rate limits.