Image Moderation

BETA

Analyze images for potential moderation issues.

POSThttps://api.safecomms.dev/moderation/imageBETA

The image moderation endpoint allows you to scan images for unsafe content such as nudity, violence, gore, and hate symbols.

Request Body

FieldTypeRequiredDescription
imagestringYesThe image to moderate. Can be a public URL or a Base64 encoded string.
languagestringNoThe language to use for the explanation (default: "English").
moderationProfileIdstringNoThe ID of a custom moderation profile to apply.
enableOcrbooleanNoExtract visible English text from the image (OCR). Default: false.
enhancedOcrbooleanNoAllocates extra resources for maximum accuracy. Slower and rarely needed for standard images. Requires `enableOcr` to be true. Default: false.
extractMetadatabooleanNoExtract EXIF metadata from the image. Default: false.

URL Restrictions

When providing a URL for the image field, please note the following restrictions:

  • Download Timeout: The image must download within 5 seconds.
  • Redirect Limit: A maximum of 3 redirects are followed.
  • Protocols: Only HTTP and HTTPS are supported.
  • Security: URLs resolving to internal or private IP addresses are immediately skipped since we cannot access them.

We enforce these restrictions to ensure a high level of quality and reliability for our service. If you have any questions or concerns, please contact our helpdesk.

Token Usage & Costs

Image moderation uses a base cost of 20 tokens per request.

FeatureCostTierCondition
Base Request20 TokensStarter+Always applied.
Non-English Language+1Pro+ Applied when language is not 'English'.
Optical Character Recognition (OCR)+3Pro+ Applied when enableOcr is true.
Enhanced OCR+8Pro+ Applied when enhancedOcr is true. Replaces standard OCR cost.
Note: Slower and rarely needed for standard images.
EXIF (Metadata)+1Starter+ Applied when extractMetadata is true.

Example Request

{
  "image": "https://example.com/image.jpg",
  "language": "English",
  "enableOcr": true,
  "extractMetadata": true
}

Example Response

{
  "isClean": false,
  "confidence": 95,
  "severity": "High",
  "categoryScores": {
    "Profanity": "None",
    "Slurs": "None",
    "Sexual": "High",
    "Hate": "None",
    "Spam": "None",
    "Bullying": "None",
    "Violence": "None"
  },
  "isBypassAttempt": false,
  "issues": [
    {
      "term": "Nudity",
      "context": "Explicit content detected"
    }
  ],
  "reason": "Contains explicit sexual content.",
  "detectedText": [
    "WARNING",
    "ADULT CONTENT"
  ],
  "metadata": {
    "Make": "Canon",
    "Model": "Canon EOS 5D Mark IV",
    "DateTime": "2023:10:27 14:30:00"
  }
}