Image Moderation

Analyze images for potential moderation issues.

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

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.
detectPiibooleanNoDetect Personally Identifiable Information (PII) such as faces, license plates, etc. Default: false.
redactPiibooleanNo Redact detected PII from the image and returns a safe image in the `safeContent` field. Requires `detectPii` to be true. Default: false.
Note: The returned URL is a signed URL that expires after 60 minutes. Your acitivity log may show a URL that is not usable, so make sure to save it during the original request.
piiCategoriesstring[]No List of PII categories to detect (e.g. ["Face", "Email"]). If omitted, all supported categories are checked.
View Supported Categories
  • face (Faces)
  • address (Addresses)
  • phone (Phone Numbers)
  • email (Email Addresses)
  • license_plate (License Plates)
  • credit_card (Credit Cards)
  • passport_id (Passports/IDs)
  • signature (Signatures)
  • ssn (Social Security Numbers)
  • dob (Date of Birth)
redactionModestringNoStyle of redaction: "blur", "box", "solid", or "pixelate". Default: "blur".

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.
PII Detection+3Starter+ Applied when detectPii is true.
PII Redaction BETA
Large images containing 5+ redaction subjects may result in reduced accuracy. We recommend manual verification for high-density scenarios.
+50
Accurately determining the exact location and boundaries of PII for redaction is significantly more complex and resource-intensive than simply detecting its presence.
Pro+ Applied when redactPii is true. Includes detection cost.

Example Request

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

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"
    }
  ],
  "detectedText": [
    "WARNING",
    "ADULT CONTENT"
  ],
  "detectedPii": [
    {
      "type": "Face",
      "value": "Human face detected",
    }
  ],
  "safeContent": "https://cdn.safecomms.dev/redacted/...",
  "metadata": {
    "Make": "Canon",
    "Model": "Canon EOS 5D Mark IV",
    "DateTime": "2023:10:27 14:30:00"
  }
}