Openinary NSFW API is a self-hosted image moderation API that:
- detects nudity with nsfwjs's model
- flags weapons, gore and drugs with Apple's MobileCLIP
- accepts any image format: JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG
- runs on a small instance: ~75 ms per image on 1 vCPU, ~140 MB of RAM, no GPU
- ships as a single Docker image, with no external service
For the full API, every setting and the benchmarks, see docs/details.md.
Warning
Weapon, gore and drug detection is a prototype: its scores are not calibrated, so test it on your own images. Read the MobileCLIP license note before any commercial use.
Or run it with Docker:
docker build -t nsfw-api .
docker run -p 8080:8080 -e API_KEY=your-key nsfw-apiThen open http://localhost:8080/playground to try it in your browser.
curl -X POST https://your-app.up.railway.app/classify \
-H "Authorization: Bearer $API_KEY" \
-F image=@photo.jpg{
"safe": false,
"flags": ["weapon"],
"nsfw": false,
"score": 0.0036,
"categories": {
"weapon": { "score": 0.91, "match": "a person holding a gun", "flagged": true },
"gore": { "score": 0.02, "match": "a photo of a bloody wound", "flagged": false },
"drugs": { "score": 0.01, "match": "a photo of illegal drugs", "flagged": false }
},
"timeMs": 76
}safe is false as soon as one flag is raised. The response also includes each nudity class's score: see the full response.
| Variable | Default | Description |
|---|---|---|
API_KEY |
(empty) | Key required on /classify. Leave empty for an open API. |
NSFW_THRESHOLD |
0.7 |
Nudity score above which an image is flagged. |
CLIP_CATEGORIES |
weapon,gore,drugs |
Extra categories to check, or none. |
CLIP_THRESHOLD |
0.5 |
Score above which a category is flagged. |
Requires Node 22.18+.
npm install
npm run prepare-models # downloads and converts the models
npm run dev # http://localhost:8080
npm testDetails | Railway template | Issues | Contact
The code is MIT, see LICENSE. The nsfwjs model is © Infinite Red (MIT). MobileCLIP-S0 is © Apple Inc., under the Apple Sample Code License copied into the image at build time.