Skip to main content
Documentation
Learning Center

Master content moderation with comprehensive guides, tutorials, and API documentation

Quick Links

Image NSFW Detection

Discuse image moderation scores user-submitted images for explicit content. Send image URLs to POST https://api.discuse.com/api/v2/check with check_images enabled, and the API returns porn, sexual, and neutral probabilities plus a hit flag per the results.images object.

How does NSFW detection work?

Discuse's computer-vision model returns three probabilities for each image, summing toward 1.0:

  • porn: likelihood the image is pornographic.
  • sexual: likelihood the image is sexually suggestive.
  • neutral: likelihood the image is safe.

A hit flag indicates the image crossed your project's NSFW thresholds. Use the raw scores to separate a clearly explicit image (auto-block) from a borderline one (human review).

How do I check an image?

Submit one or more image URLs and enable the image check with check_images:

curl -X POST https://api.discuse.com/api/v2/check \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "content": {
      "image_urls": ["https://example.com/user-upload.jpg"]
    },
    "settings": {
      "check_images": true
    }
  }'

A single request accepts up to 10 image URLs.

Response format

{
  "has_violations": true,
  "cached": false,
  "message": "NSFW content detected",
  "results": {
    "hits": true,
    "images": {
      "status": "ok",
      "porn": 0.95,
      "sexual": 0.85,
      "neutral": 0.02,
      "hit": true
    }
  },
  "usage": {
    "api_requests_used": 12,
    "api_requests_limit": 2000,
    "api_requests_remaining": 1988
  }
}

The image result lives under results.images. processing_time_ms is only present when timing is enabled in your project settings.

Checking multiple images

{
  "content": {
    "image_urls": [
      "https://example.com/image1.jpg",
      "https://example.com/image2.jpg",
      "https://example.com/image3.jpg"
    ]
  },
  "settings": {
    "check_images": true
  }
}

Each image scanned counts separately against your image-scan quota.

How do I interpret the scores?

porn, sexual, and neutral are probabilities from 0.0 to 1.0. For an explicit image, porn is high and neutral is low; for a safe image, neutral dominates.

function interpretImageResult(result) {
  const img = result.results.images;

  if (img.porn > 0.8) {
    return 'block';   // automatically reject
  } else if (img.porn > 0.5 || img.sexual > 0.7) {
    return 'review';  // queue for human review
  } else if (img.sexual > 0.5) {
    return 'warn';    // allow with a content-warning label
  } else {
    return 'allow';
  }
}

You can also gate on the hit flag, which already applies your project's threshold_images_porn and threshold_images_sexual settings.

Use cases

Social platforms

Screen profile pictures and post images before they go live:

async function handleImageUpload(imageUrl) {
  const result = await checkImage(imageUrl);
  const img = result.results.images;

  if (img.porn > 0.7) {
    throw new Error('This image violates our community guidelines');
  }
  if (img.sexual > 0.7) {
    return { url: imageUrl, hasContentWarning: true };
  }
  return { url: imageUrl, hasContentWarning: false };
}

Marketplaces

Apply a stricter cutoff for product imagery:

def validate_product_image(image_url):
    result = check_image(image_url)
    img = result['results']['images']

    if img['porn'] > 0.3 or img['sexual'] > 0.3:
        return {'approved': False, 'reason': 'Image contains inappropriate content'}

    return {'approved': True}

Best practices

Scan before permanent storage

async function processUpload(file) {
  const tempUrl = await uploadToTemp(file);
  const result = await checkImage(tempUrl);

  if (result.has_violations) {
    await deleteTempFile(tempUrl);
    throw new Error('Image rejected');
  }
  return await moveToPermanent(tempUrl);
}

Combine with text moderation

A single request can scan an image and its caption together:

{
  "content": {
    "text": "Check out this photo from my vacation!",
    "image_urls": ["https://example.com/vacation.jpg"]
  },
  "settings": {
    "check_sentiment": true,
    "check_spam": true,
    "check_images": true
  }
}

Use cached results

Cached responses do not count against your quota, so re-displaying or re-validating an already-scanned image is free. The cached flag in the response tells you when a result came from cache.

Usage limits

Plan Monthly Image Scans Overage Rate
Basic 500 Not available
Gold 2,000 $0.00075/scan
Platinum 5,000 $0.00064/scan (15% discount)
Ultimate 10,000 $0.00056/scan (25% discount)

Integration examples

Node.js

const checkImage = async (imageUrl) => {
  const response = await fetch('https://api.discuse.com/api/v2/check', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': process.env.DISCUSE_API_KEY
    },
    body: JSON.stringify({
      content: { image_urls: [imageUrl] },
      settings: { check_images: true }
    })
  });

  return response.json();
};

Python

import os
import requests

def check_image(image_url):
    response = requests.post(
        'https://api.discuse.com/api/v2/check',
        headers={
            'Content-Type': 'application/json',
            'X-API-Key': os.environ['DISCUSE_API_KEY']
        },
        json={
            'content': {'image_urls': [image_url]},
            'settings': {'check_images': True}
        }
    )
    return response.json()

Next steps

Written by the Discuse Team · Last updated June 2026

Related Articles

Text Analysis and Sentiment Detection

Detect spam, toxicity, profanity, and analyze sentiment in text content

Spam Detection

AI-powered spam filtering for text and messages

File Antivirus Scanning

Protect your platform from malware, viruses, and malicious files