Image Moderation
Analyze images for potential moderation issues.
POST
https://api.safecomms.dev/moderation/imageThe image moderation endpoint allows you to scan images for unsafe content such as nudity, violence, gore, and hate symbols.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| image | string | Yes | The image to moderate. Can be a public URL or a Base64 encoded string. |
| language | string | No | The language to use for the explanation (default: "English"). |
| moderationProfileId | string | No | The ID of a custom moderation profile to apply. |
| enableOcr | boolean | No | Extract visible English text from the image (OCR). Default: false. |
| enhancedOcr | boolean | No | Allocates extra resources for maximum accuracy. Slower and rarely needed for standard images. Requires `enableOcr` to be true. Default: false. |
| extractMetadata | boolean | No | Extract EXIF metadata from the image. Default: false. |
| detectPii | boolean | No | Detect Personally Identifiable Information (PII) such as faces, license plates, etc. Default: false. |
| redactPii | boolean | No | 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. |
| piiCategories | string[] | No | List of PII categories to detect (e.g. ["Face", "Email"]). If omitted, all supported categories are checked. View Supported Categories
|
| redactionMode | string | No | Style 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.
| Feature | Cost | Tier | Condition |
|---|---|---|---|
| Base Request | 20 Tokens | Starter+ | Always applied. |
| Non-English Language | +1 | Pro+ | Applied when language is not 'English'. |
| Optical Character Recognition (OCR) | +3 | Pro+ | Applied when enableOcr is true. |
| Enhanced OCR | +8 | Pro+ | Applied when enhancedOcr is true. Replaces standard OCR cost. Note: Slower and rarely needed for standard images. |
| EXIF (Metadata) | +1 | Starter+ | Applied when extractMetadata is true. |
| PII Detection | +3 | Starter+ | 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"
}
}