---
title: "Deploy NSFW API"
description: "Self-hosted image moderation API: nudity, weapons, gore and drugs."
category: "AI/ML"
url: https://railway.com/deploy/nsfw-api
---

# Deploy NSFW API

Self-hosted image moderation API: nudity, weapons, gore and drugs.

**[Deploy NSFW API on Railway](https://railway.com/template/nsfw-api)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/nsfw-api/manifest.json

- **Creator:** Florian's Projects
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### nsfw-api

- **Source:** openinary/nsfw-api
- **Public domain:** Yes

## Documentation

# Deploy and Host NSFW API on Railway

NSFW API is a self-hosted image moderation API. Send an image to `POST /classify` and get back whether it is safe: nudity scores from nsfwjs's MobileNetV2, plus weapons, gore and drugs detection with Apple's MobileCLIP-S0. Both models run on CPU with ONNX Runtime: no GPU, no third-party service.

## About Hosting NSFW API

The service builds from the repository's Dockerfile into a small distroless image (~122 MB compressed) with both models inside, so nothing is downloaded at boot. The models load in under a second and the healthcheck only turns green once they are ready. On 1 vCPU it answers in ~75 ms per image with ~125 MB of RAM at rest. An API key is generated for you, and a playground at `/playground` lets you try it from a browser. Turn on App Sleeping to pay almost nothing while it is idle.

## Common Use Cases

- Moderate user uploads (avatars, posts, listings) before they are published
- Flag nudity, weapons, gore or drugs in an image pipeline or an image CDN such as Openinary
- Keep images private: they only live in memory for the length of the request, nothing is stored

## Dependencies for NSFW API Hosting

- None at runtime: a single service, no database and no volume
- The models are fetched from Hugging Face at pinned revisions during the build

### Implementation Details

```bash
curl -H "Authorization: Bearer $API_KEY" -F image=@photo.jpg https:///classify
```

The response contains `safe`, `flags` (for example `["nsfw"]` or `["weapon"]`), the nudity `predictions` and a score per category. Send ~512 px thumbnails rather than originals: the models only look at 224–256 px, and a 4000×3000 WebP takes ~414 ms against ~69 ms for its thumbnail.

The MobileCLIP-S0 weights come from a copy published under Apple's 2024 sample code license; Apple has since moved MobileCLIP to a research-only license. Read the license note in the [README](https://github.com/openinary/nsfw-api) before commercial use.

## Why Deploy NSFW API on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying NSFW API on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/nsfw-api
