SFW API
Menu

Compare

SFW API vs NSFW.js

Last updated 2026-11-17

NSFW.js is an open-source TensorFlow.js model that classifies an image into five classes, in the browser or in Node. The SFW API is a hosted endpoint that returns a level from 0 to 3, three scores, art and adult-object flags and a policy verdict. Facts below are from the NSFW.js README and npm page in November 2026 (version 4.4.0).

SFW APINSFW.js
Runshosted API (Germany)in the browser (WebGL, WebGPU, WASM) or Node with @tensorflow/tfjs-node
Price500 free credits/month, then $10 for 10,000 ($1.00/1k), down to $0.50/1kfree (MIT); you host the model files
Outputlevel 0–3, three scores, art and sex_object flags, policy verdictprobabilities for Drawing, Hentai, Neutral, Porn and Sexy
Modelsone versioned modelMobileNetV2 (about 2.8 MB), MobileNetV2Mid (about 4.4 MB), InceptionV3 (about 23 MB)
Stated accuracyper level with confidence intervals on Accuracy"~90% with small and ~93% with midsized model", without a published test set
GIF/videoframe by frame on the same endpoint (video on paid accounts)single images or video frames you pass in; classifyGif was removed in 2024
Adult objectssex_object flagno equivalent class
Enforcementon your server, the client cannot skip itin the browser it runs on the user's device, so a check there can be bypassed; run it in Node to enforce

NSFW.js is enough for a client-side hint, such as blurring a preview before upload, or for a hobby project where a five-class guess is fine and no image may leave the device. Choose the SFW API for the check you enforce: on the server, with a grade between swimwear and implied nudity, GIF and video support, and no model files to host and update.

Mapping NSFW.js classes to levels

NSFW.jsSFW API
Pornlevel 3 Explicit
Hentaiart flag with level 3
Sexylevel 1 Revealing or level 2 Implied Nudity: one class covers both
Drawingart flag with level 0 or 1
Neutrallevel 0 Everyday

Sexy is where most moderation decisions are made, and it puts lingerie, swimwear and covered nudity in one bucket. The SFW API splits that bucket into levels 1 and 2 so you can choose which one blocks.

The same check in both

// NSFW.js in Node
import * as tf from '@tensorflow/tfjs-node';
import * as nsfwjs from 'nsfwjs';
const model = await nsfwjs.load();
const image = tf.node.decodeImage(bytes, 3) as tf.Tensor3D;
const top = (await model.classify(image))[0];
image.dispose();
const blocked = top.className === 'Porn' || top.className === 'Hentai';

// SFW API (npm install @sfwapi/sdk)
const r = await api.analyzeFile(bytes, { policy: { block_level: 2 } });
const blocked = r.policy?.blocked;

Related

Next steps

Read the quickstart for a first request, see pricing for the free tier and prepaid packs, or get a free API key and start with your own images.