بررسی محتوای تصویر
POST /v1/moderations/image یک تصویر (URL یا data: base64) را با یکی از سه مدل طبقهبند بررسی میکند و امتیاز NSFW بین ۰ تا ۱ بههمراه برچسب normal / flagged / nsfw برمیگرداند. تصمیم نهایی با شماست، این اندپوینت چیزی را مسدود نمیکند. فهرست طبقهبندها و قیمت هر کدام از GET /v1/moderation-models میآید.
/v1/moderations/imageاحراز هویت BearerClassify 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.
بدنه درخواستالزامی
| فیلد | نوع | توضیح |
|---|---|---|
imageالزامی | 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. نمونه: |
model | string | Classifier model to use. Omit for your account's default. See GET /v1/moderation-models for available options with pricing. نمونه: |
نمونه
پاسخها
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-modelsاحراز هویت BearerList 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.
نمونه
پاسخها
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
}
}