Image moderation
POST /v1/moderations/image classifies an image (URL or base64 data:) with one of three classifier models and returns an NSFW score from 0 to 1 plus a normal / flagged / nsfw label. The decision stays yours, nothing is blocked by this endpoint. GET /v1/moderation-models lists the classifiers and their prices.
/v1/moderations/imageBearer authClassify an image for NSFW content
Returns a confidence score (0.0–1.0) and label for the image at the
given URL. You can select which classifier model to use via the
optional model field, see GET /v1/moderation-models for
available options with pricing.
When to call this:
- Before sending an image to Real-ESRGAN or any other image-only model that doesn't have a prompt for upstream safety filters.
- As part of your own user-generated-content moderation pipeline.
- When you want a score you control, independent of our automatic pre-flight setting.
Billing: per-model pricing (see GET /v1/moderation-models).
Settled immediately. Call costs appear in your dashboard alongside
other predictions.
Model selection: pass the model field to choose a classifier.
If omitted, your account's admin-assigned default is used (or the
system default if none assigned).
Labels:
normal: score is below both thresholds.flagged: score ≥ flagged threshold but < blocked threshold.nsfw: score ≥ blocked threshold.
Notes:
- Both
http:///https://URLs and base64data:URIs are supported. - Max image size is 25 MB.
- The response
modelfield tells you which classifier was used.
Request bodyrequired
| Field | Type | Description |
|---|---|---|
imagerequired | string (uri) | Public HTTP(S) URL or base64 data URI of the image to classify. HTTP(S) URLs must be reachable either directly from our Iran-local servers (e.g., ArvanCloud) or via our outbound tunnel. Example: |
model | string | Classifier model to use. Omit for your account's default. See GET /v1/moderation-models for available options with pricing. Example: |
Example
Responses
200Classification completed.
400Invalid image URL, unreachable source, or unsupported image
format. The code distinguishes the cases:
INVALID_IMAGE_URL: URL malformed or empty.IMAGE_FETCH_FAILED: could not download the bytes.UNSUPPORTED_IMAGE_FORMAT: bytes can't be decoded; re-encode as JPEG, PNG, WebP, or GIF.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401
}
}402Insufficient credit balance for the check.
409Idempotency key conflict: you sent the same Idempotency-Key with
a different request body.
413Image exceeds the maximum allowed size (25 MB default).
429Too many requests. Back off and retry after a short delay.
Check the Retry-After header for guidance.
499Your HTTP client cancelled the request before the gateway finished. No charge: the hold has been released. The most common cause is a 30 s default client timeout against a model whose p95 latency is 45-60 s; bump your client timeout to 120 s.
Retries with the same Idempotency-Key will replay this 499
forever (the prior outcome is "you cancelled"). For an actual
re-attempt, mint a fresh Idempotency-Key. See
docs/CUSTOMER_ERROR_HANDLING.md §3 for the full contract.
{
"error": {
"code": "CLIENT_CLOSED",
"message": "Client disconnected before response",
"status": 499
}
}503Classifier or upload upstream temporarily unavailable.
504The gateway's 120 s upstream deadline elapsed before the upstream
provider produced a response. Retry with the same
Idempotency-Key so a delayed-but-eventually-successful upstream
call can be replayed instead of re-charged. Consider switching
to a faster model or capping max_tokens if this recurs.
{
"error": {
"code": "UPSTREAM_TIMEOUT",
"message": "Upstream did not respond before timeout",
"status": 504
}
}/v1/moderation-modelsBearer authList available content moderation models
Returns the available NSFW classifier models with display names,
per-check pricing, and estimated speed. Use the id from this
list in the model field of POST /v1/moderations/image.
Example
Responses
200Moderation model list.
401Authentication failed. Either the Authorization header is missing,
the key format is invalid, or the key doesn't match any active account.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required",
"status": 401
}
}