All Products
Search
Document Center

AI Guardrails:Image Moderation 2.0 Asynchronous Detection API

Last Updated:Mar 31, 2026

Image Moderation 2.0 detects content in images that violates online regulations, disrupts platform order, or degrades user experience. It supports over 40 risk labels and over 40 risk control items. Use the returned risk labels and confidence scores to build review or governance workflows aligned with your industry standards or platform rules. For billing details, see Image Moderation 2.0 overview and billing.

The asynchronous detection service includes two API operations:

  • ImageAsyncModeration: Submits an asynchronous image moderation task.

  • DescribeImageModerationResult: Retrieves the result of a moderation task.

Prerequisites

Before you begin, make sure that you have:

  • An Alibaba Cloud account. Register now if you don't have one.

  • Content Moderation activated with pay-as-you-go billing. activated the service if you haven't already. Activation is free; billing starts when you make API calls. For details, see Billing.

  • An AccessKey created in RAM. If you use a RAM user's AccessKey, grant the RAM user the AliyunYundunGreenWebFullAccess permission using your Alibaba Cloud account. For details, see RAM authorization.

  • The software development kit (SDK) integrated. See Image Moderation 2.0 SDK and access guide.

ImageAsyncModeration

Submits an asynchronous image moderation task. Results are not returned in real time — retrieve them using a callback or by polling.

Endpoint

RegionPublic endpointVPC endpointSupported services
Singaporehttps://green-cip.ap-southeast-1.aliyuncs.comhttps://green-cip-vpc.ap-southeast-1.aliyuncs.combaselineCheck_global

Billing

This is a paid operation. Only requests that return HTTP 200 are billed. For pricing, see Billing.

Rate limit

100 queries per second (QPS) per Alibaba Cloud account. Exceeding this limit throttles your requests. To request a higher QPS limit, contact your account manager.

Debug

Use Alibaba Cloud OpenAPI to debug ImageAsyncModeration online and explore sample code and SDK dependencies.

Important

Online debugging calls the API using your current account and counts toward your billable usage.

Image requirements

ConstraintLimit
Supported formatsPNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, HEIF (longest edge < 8,192 px), GIF (first frame only), ICO (last image only)
Max file size20 MB
Max dimensions16,384 px per side; 167 million total pixels
Recommended resolution> 200 × 200 px (low resolution may reduce detection accuracy)
Download timeout3 seconds (requests that exceed this return a timeout error)

How to pass images

Three methods are supported — choose one per request:

  • Image URL: Pass imageUrl. The URL must be publicly accessible, up to 2,048 characters, and must not contain Chinese characters.

  • OSS authorization: Pass ossBucketName, ossObjectName, and ossRegionId. First grant the AliyunCIPScanOSSRole role on the Cloud Resource Access Authorization page.

  • Local image upload: Handled by the SDK — uploaded files are stored for 30 minutes only. For code examples, see Image Moderation 2.0 SDK and integration guide.

Request parameters

For common request parameters, see Common parameters.

The request body is a JSON object:

ParameterTypeRequiredExampleDescription
ServiceStringYesbaselineCheck_globalThe detection service. Valid value: baselineCheck_global (general baseline detection). For service differences, see Service description.
ServiceParametersJSONStringYesThe detection parameters as a JSON string. See the ServiceParameters table below.

ServiceParameters

ParameterTypeRequiredExampleDescription
imageUrlStringConditionalhttps://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.pngThe URL of the image to detect. Required when using the image URL method. The URL must be publicly accessible, up to 2,048 characters, and must not contain Chinese characters. Pass only one URL per request.
ossBucketNameStringConditionalbucket_01The name of the authorized OSS bucket. Required when using the OSS authorization method.
ossObjectNameStringConditional2022023/04/24/test.jpgThe name of the file in the OSS bucket. Pass the original file name as stored in OSS — do not URL-encode it, even if it contains Chinese characters or spaces.
ossRegionIdStringConditionalcn-beijingThe region of the OSS bucket. Required when using the OSS authorization method.
dataIdStringNoimg123****A custom ID to associate with the detected image. Up to 64 characters: letters, digits, underscores (_), hyphens (-), and periods (.).
callbackStringNohttp://www.aliyundoc.comThe callback URL to receive detection results. Supports HTTP and HTTPS. If omitted, poll for results using DescribeImageModerationResult. The callback endpoint must support POST requests with UTF-8 encoding and accept three form parameters: ReqId, Checksum, and Content. Return HTTP 200 to confirm receipt. If your endpoint returns any other status code, Content Moderation retries up to 3 times. If all 3 retries fail, the result is no longer pushed.
seedStringNoabc****A random string used to generate the callback Checksum. Required when callback is set. Up to 64 characters: letters, digits, and underscores.
cryptTypeStringNoSHA256The encryption algorithm for callback verification. Content Moderation encrypts user UID + seed + content using this algorithm and sends the result as Checksum. Valid values: SHA256 (default), SM3 (HMAC-SM3, returns lowercase hexadecimal).
intervalIntegerNo1The frame capture interval for GIF and long image detection. When set, the system captures one frame for every interval frames. If omitted, only the first frame of a GIF is detected, and long images are compressed before detection. Must be used with maxFrameNum.
maxFrameNumIntegerNo10The maximum number of frames to capture. Default: 10. Range: 1–100. If interval × maxFrameNum is less than the total number of frames, the interval is automatically adjusted to improve detection coverage. Billing is based on the actual number of frames detected.
refererStringNowww.aliyun.comThe Referer request header, for scenarios such as hotlink protection. Up to 256 characters.
infoTypeStringYescustomImage,textInImageThe types of auxiliary information to return. Valid values: customImage (custom image library hits), textInImage (text in image), publicFigure (public figure hits), logoData (logo hits). Specify multiple types separated by commas.

Long image detection logic

Long images are detected when interval is set:

  • Long vertical image (height > 400 px and height-to-width ratio > 2.5): sliced into round(height / width) sections.

  • Long horizontal image (width > 400 px and width-to-height ratio > 2.5): sliced into round(width / height) sections.

Callback verification

The Checksum is computed as SHA256 (or SM3) of user UID + seed + content, where user UID is your Alibaba Cloud account ID — not a RAM user ID. To verify authenticity, recompute the checksum on your server and compare it against the received Checksum.

Find your Alibaba Cloud account ID in the Alibaba Cloud Management Console.

Response elements

ParameterTypeExampleDescription
CodeInteger200The status code. See Status codes.
MsgStringOKThe response message.
RequestIdStringABCD1234-1234-1234-1234-123****The request ID.
DataObjectThe detection result.
Data.ReqIdStringABCD1234-1234-1234-1234-123****The request ID for querying the moderation result. Pass this value to DescribeImageModerationResult.
Data.DataIdStringimg123******The data ID corresponding to the detected image.

Examples

Request

{
    "Service": "baselineCheck",
    "ServiceParameters": {
        "imageUrl": "https://img.alicdn.com/tfs/TB1Mq6ZmCslXu8jSZFuXXXg7FXa-1440-568.jpg",
        "dataId": "img123******",
        "interval": 1,
        "maxFrameNum": 50
    }
}

Response

{
    "Msg": "OK",
    "Code": 200,
    "RequestId": "ABCD1234-1234-1234-1234-1234XYZ",
    "Data": {
        "ReqId": "ABCD1234-1234-1234-1234-1234XYZ",
        "DataId": "img123******"
    }
}

DescribeImageModerationResult

Retrieves the result of an Image Moderation 2.0 moderation task. This operation is not billed.

We recommend polling for results at least 30 seconds after submitting the task, using 30 seconds as the query interval. Results are stored for 3 days and automatically deleted afterward. When polling without a callback, results are typically available within 24 hours.

Rate limit

100 QPS per Alibaba Cloud account.

Debug

Use Alibaba Cloud OpenAPI to debug DescribeImageModerationResult online.

Request parameters

ParameterTypeRequiredExampleDescription
ReqIdStringYesABCD1234-1234-1234-1234-123****The request ID returned by ImageAsyncModeration (Data.ReqId).

Response elements

ParameterTypeExampleDescription
CodeInteger200The status code. See Status codes.
MsgStringOKThe response message.
RequestIdStringABCD1234-1234-1234-1234-123****The request ID.
DataObjectThe image detection result.

Data

ParameterTypeExampleDescription
DataIdStringimg123****The data ID from the original detection request.
RiskLevelStringhighThe overall risk level. Valid values: high, medium, low, none. See Risk level handling.
ResultArrayThe detected risk labels and confidence scores. See the Result table below.
FrameNumInteger10The total number of frames captured from the image.
FrameStringA JSON string containing per-frame detection results. Each frame includes: tepmUrl (temporary URL, valid for 5 minutes), Result, and optionally CustomImage, TextInImage, PublicFigure, and LogoData. When no frames are captured, only the current image result is returned.

Result

ParameterTypeExampleDescription
LabelStringviolent_explosionThe risk label. A single image may return multiple labels. For supported labels, see Labels supported by general baseline detection. 2.0
ConfidenceFloat81.22The confidence score, from 0 to 100 with two decimal places. Some labels do not return a confidence score.
DescriptionStringFireworks contentA human-readable description of the label. This field is for reference only and may change — base your processing logic on Label, not Description.

Risk level handling

Risk levelRecommended action
highHandle directly (block or remove content)
mediumRoute to manual review
lowProcess only when high recall is required; otherwise treat as none
noneNo risk detected

Configure risk score thresholds in the Content Moderation console.

Examples

Request

{
    "ReqId": "ABCD1234-1234-1234-1234-123****"
}

Response — risky content detected

{
    "Msg": "success",
    "Code": 200,
    "Data": {
        "DataId": "img123****",
        "Result": [
            {
                "Label": "pornographic_adultContent",
                "Confidence": 81,
                "Description": "Adult pornography"
            },
            {
                "Label": "sexual_partialNudity",
                "Confidence": 98,
                "Description": "Body nudity or sexual content"
            },
            {
                "Label": "violent_explosion",
                "Confidence": 70,
                "Description": "Fireworks content"
            },
            {
                "Label": "violent_explosion_lib",
                "Confidence": 81,
                "Description": "Fireworks content_hit in custom library"
            }
        ],
        "RiskLevel": "high",
        "Frame": "[{\"Result\":[{\"Confidence\":98.18,\"Label\":\"contraband_gamble\"},{\"Confidence\":96.39,\"Label\":\"pornographic_adultContent\"},{\"Confidence\":95.27,\"Label\":\"violent_explosion\"}],\"TempUrl\":\"http://www.aliyundoc.com/test1.jpg\"},{\"Result\":[{\"Confidence\":91.18,\"Label\":\"violent_explosion_lib\"}],\"TempUrl\":\"http://www.aliyundoc.com/test2.jpg\"}]",
        "FrameNum": 2
    },
    "RequestId": "ABCD1234-1234-1234-1234-123****"
}

Response — no risky content

{
    "Msg": "success",
    "Code": 200,
    "Data": {
        "DataId": "img123****",
        "Result": [
            {
                "Label": "nonLabel",
                "Confidence": null,
                "Description": "No risk detected"
            }
        ],
        "RiskLevel": "none",
        "Frame": "[{\"Result\":[{\"Label\":\"nonLabel\"}],\"TempUrl\":\"http://www.aliyundoc.com/test1.jpg\"},{\"Result\":[{\"Label\":\"nonLabel\"}],\"TempUrl\":\"http://www.aliyundoc.com/test2.jpg\"}]",
        "FrameNum": 2
    },
    "RequestId": "ABCD1234-1234-1234-1234-123****"
}

Response — image matched in review-free library

{
    "Msg": "success",
    "Code": 200,
    "Data": {
        "DataId": "img123****",
        "Result": [
            {
                "Label": "nonLabel_lib",
                "Confidence": 99.66,
                "Description": "Hit in review-free library"
            }
        ],
        "RiskLevel": "none",
        "Frame": "[{\"Result\":[{\"Confidence\":99.66,\"Label\":\"nonLabel_lib\"}],\"TempUrl\":\"http://www.aliyundoc.com/test1.jpg\"},{\"Result\":[{\"Confidence\":81.18,\"Label\":\"nonLabel_lib\"}],\"TempUrl\":\"http://www.aliyundoc.com/test2.jpg\"}]",
        "FrameNum": 2
    },
    "RequestId": "ABCD1234-1234-1234-1234-123****"
}
The request and response examples use line breaks and indentation for readability. Actual API responses are not formatted.

Risk label description table

For descriptions of all risk labels, see Risk label description table. Labels can be enabled or disabled in the console, and some support more granular detection scopes. For configuration details, see Console user guide.

Store the risk labels and confidence scores returned by the API for a period of time. This allows you to reference them for future content governance, set priorities for manual review, and implement tiered and categorized governance measures.

Status codes

The system bills only requests that return code 200. All other codes are not billed.

CodeDescription
200The request succeeded.
280The task is being processed.
400A request parameter is empty.
401A request parameter is incorrect.
402A request parameter exceeds the allowed length. Check and adjust the value.
403The request exceeds the QPS limit. Reduce your request rate.
404Failed to download the image. Check the image URL or retry.
405The image download timed out. The image may be inaccessible. Check and retry.
406The image is too large. Reduce the image size and retry.
407The image format is not supported. Check the format and retry.
408The account does not have permission to call this operation. Make sure the service is activated, the account has no overdue payments, and the calling account is authorized.
500A system error occurred.