Docs/APIs/NSFW Image Detector

NSFW Image Detector

Detect NSFW content

OperationalCredits 10 per callp50 3047msImagesStar

Overview

An NSFW image detection API for user uploads: check avatars, listings and chat attachments before other users see them. The image is scaled to 512 pixels on its longest side and run through a vision transformer classifier with two labels, sfw and nsfw, which APIVerve hosts itself, so images are not passed to a third-party moderation service. An image is flagged when its nsfw score reaches 0.6. Every plan gets isNSFW and isSafe; paid plans add that score as confidence, from 0 to 1, so you can apply a stricter or looser threshold, and the verdict label. It answers one question, explicit or not; there are no separate labels for violence, gore or weapons.

Live Test NSFW Image Detector API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

POSThttps://api.apiverve.com/v1/nsfwimagedetector
curl -X POST https://api.apiverve.com/v1/nsfwimagedetector \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "image": "http://images.cocodataset.org/val2017/000000039769.jpg"
}'

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
imageOptionalstringAn image file to classify (JPG, PNG or GIF, up to 5 MB), or a public image URL

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "isNSFW": false,
    "isSafe": true,
    "confidence": 0.987,
    "category": "neutral"
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
isNSFWbooleanfalseWhether the image contains NSFW content
isSafebooleantrueWhether the image is safe for general audiences
confidencePremiumnumber0.987How likely the image is NSFW, from 0 to 1; 0 on a clearly safe image
categoryPremiumstring"neutral"The verdict as a label, sfw or nsfw; nsfw once the score reaches 0.6, so it always agrees with isNSFW

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

Avatar Upload Filtering
Dating platforms inspect incoming profile pictures and immediately reject submissions flagged as adult content before they display publicly.
Marketplace Listing Screening
When sellers publish new product photos, e-commerce sites check each image to prevent explicit inventory from appearing in public catalog searches.
Community Chat Moderation
To keep discussion rooms family-friendly, messaging services block shared GIF and image attachments whenever the safe content check fails.
Support Ticket Attachment Triage
Route incoming helpdesk image files through screening checks so support representatives avoid unexpected exposure to explicit material while troubleshooting.

Set up NSFW Image Detector

Ready to put it to work? Set up NSFW Image Detector on APIVerve.

More in Images:

Was this page helpful?