All Products
Search
Document Center

AI Guardrails:Synchronous detection

Last Updated:Mar 31, 2026

Submits synchronous image moderation tasks and returns results in real time. Use this operation to detect pornographic content, terrorist content, ad violations, QR codes, undesirable scenes, and logos in images.

Supported scenarios

Scene valueScenarioLabels returned
pornPornography detectionnormal, porn, sexy
terrorismTerrorist content detectionnormal, bloody, explosion, outfit, logo, weapon, politics, violence, crowd, parade, carcrash, flag, location, drug, gamble, others
adAd violation detectionnormal, politics, porn, abuse, terrorism, contraband, spam, npx, qrcode, programCode, ad
qrcodeQR code detectionnormal, qrcode, programCode
liveUndesirable scene detectionnormal, meaningless, PIP, smoking, drivelive, drug, gamble
logoLogo detectionnormal, TV, trademark

Usage notes

Response time: Results are typically returned within 1 second. The maximum allowed response time is 6 seconds — set your client timeout accordingly. In high-load scenarios or when images are large or text-heavy, response time may increase.

Image requirements:

  • Supported formats: PNG, JPG, JPEG, BMP, GIF, WEBP

  • Maximum size: 20 MB

  • Download timeout: 3 seconds. If the image cannot be downloaded within 3 seconds, a timeout error is returned.

  • Minimum recommended resolution: 256 × 256 pixels

  • URLs must be HTTP or HTTPS, up to 2,048 characters

Storage: Moderation response time depends on image download speed. Use a stable storage service such as Object Storage Service (OSS) or Content Delivery Network (CDN) to host images.

Multiple scenarios: Specifying multiple scenes in a single request incurs the cumulative fee of all specified scenarios.

GIF and long images: By default, only the first frame is moderated. Use interval and maxFrames together to moderate additional frames. Billing is based on the actual number of frames moderated.

Asynchronous moderation: This operation returns results synchronously. If you do not need real-time results, use the asynchronous moderation operation instead.

QPS limit

50 calls per second per account. Exceeding this limit triggers throttling.

Request syntax

POST http(s)://[Endpoint]/green/image/scan

Request parameters

Top-level parameters

ParameterTypeRequiredExampleDescription
bizTypeStringNodefaultThe business scenario. Create business scenarios in the Content Moderation console. For more information, see Customize policies for machine-assisted moderation.
scenesStringArrayYes["porn","terrorism"]The moderation scenarios. Valid values: porn, terrorism, ad, qrcode, live, logo. Specify multiple values to run multiple scenarios in a single request.
tasksJSONArrayYesThe moderation tasks to submit. Each element is a task object. Maximum: 100 elements per request. To submit 100 tasks at a time, you must raise the relevant concurrency limit to a number greater than 100.

task

ParameterTypeRequiredExampleDescription
clientInfoJSONObjectNo{"userId":"12023****","userNick":"Mike","userType":"others"}The client information. For the structure, see the "Common request parameters" section of Common parameters. The task-level clientInfo takes priority over the global one.
dataIdStringNocfd33235-71a4-468b-8137-a5ffe323****The ID of the object to moderate. Accepted characters: letters, digits, underscores (_), hyphens (-), and periods (.). Maximum length: 128 characters. This ID is returned in the response for correlation.
urlStringYeshttp://www.aliyundoc.com/xxx.jpgThe publicly accessible HTTP or HTTPS URL of the image. Maximum length: 2,048 characters.
extrasJSONObjectNoAdditional parameters. Not required for standard image moderation.
intervalIntegerNo2The frame sampling interval for GIF or long image moderation. One frame is captured for every interval frames. Must be used together with maxFrames.
maxFramesIntegerNo10The maximum number of frames to capture from a GIF or long image. Default value: 1. If interval × maxFrames is less than the total frame count, the system automatically adjusts the interval to evenly distribute captures across the image.

Long image frame count calculation:

OrientationConditionFrame count
PortraitHeight > 400 px, height/width ratio > 2.5round(height / width)
HorizontalWidth > 400 px, width/height ratio > 2.5round(width / height)

Response parameters

Top-level fields

ParameterTypeExampleDescription
codeInteger200The HTTP status code. For a list of status codes, see Common error codes.
msgStringOKThe response message.
requestIdString69B41AE8-1234-1234-1234-12D395695D2DThe request ID.
dataJSONArrayThe moderation results, one element per submitted task. Each element contains the fields described in the following sections.

Per-task fields

ParameterTypeExampleDescription
codeInteger200The HTTP status code for this task.
msgStringOKThe response message for this task.
dataIdStringcfd33235-71a4-468b-8137-a5ffe323****The ID of the moderated object, echoed from the request.
taskIdStringimg4wlJcb7p4wH4lAP3111111-123456The moderation task ID.
urlStringhttp://www.aliyundoc.com/xxx.jpgThe URL of the moderated image.
storedUrlStringhttp://www.aliyundoc.comThe OSS URL where image evidence is stored. Returned only when the evidence storage feature is enabled and the image matches the configured rule.
extrasJSONObjectAdditional information. When ad is specified in scenes, this field includes hitLibInfo — an array describing custom text library matches.
resultsJSONArrayThe moderation results, one element per specified scene. For the structure, see result.

result

ParameterTypeExampleDescription
sceneStringpornThe moderation scenario. Matches the value specified in scenes.
labelStringsexyThe category of the moderation result. See Label values by scene.
sublabelStringpornThe subcategory of the result. Returned for porn and terrorism scenes only. Not returned by default.
suggestionStringblockThe recommended action. Valid values: pass (no action needed), review (requires manual review), block (contains violations; delete or block). Use suggestion, label, and sublabel together to determine the appropriate action.
rateFloat91.54The confidence score, from 0 to 100. A higher score indicates higher confidence. For pass results, a higher score means the content is more likely normal; for review or block results, a higher score means violations are more likely present.
framesJSONArrayFrame URLs for truncated long images or GIF images. Each element contains rate (confidence score) and url (temporary URL, valid for 5 minutes).
hintWordsInfoJSONArrayThe terms matched by violation text detected in the image. Returned for ad scene only. Each element contains context (the matched term).
qrcodeDataStringArray["http://www.aliyundoc.com/01ZZOliO"]The decoded URLs or text from detected QR codes. Returned for qrcode scene only.
qrcodeLocationsJSONArrayThe coordinates of detected QR codes. For the structure, see qrcodeLocation.
programCodeDataJSONArrayThe location information of detected mini program codes. Returned for qrcode scene only, when mini program code detection is enabled. For the structure, see programCodeData.
logoDataJSONArrayThe information about detected logos. Returned for logo scene only. For the structure, see logoData.
sfaceDataJSONArrayThe information about faces detected in terrorist content. Returned for terrorism scene only. For the structure, see sfaceData.
ocrDataArray["Haokan"]The full text detected in the image by OCR. Not returned by default.

Label values by scene

SceneLabels
pornnormal (normal), sexy (sexy content), porn (pornographic content)
terrorismnormal, bloody (bloody content), explosion (explosion and smoke), outfit (special costume), logo (special logo), weapon, politics (political content), violence, crowd, parade, carcrash (car crash), flag, location (landmark), drug, gamble (gambling), others
adnormal, ad (other ads), politics (political text), porn (pornographic text), abuse (abusive text), terrorism (terrorist text), contraband (prohibited text), spam (junk text), npx (overlay ad), qrcode (QR code), programCode (mini program code)
qrcodenormal, qrcode (QR code), programCode (mini program code)
livenormal, meaningless (blank or empty screen), PIP (Picture-in-Picture), smoking, drivelive (streaming while driving), drug, gamble (gambling)
logonormal, TV (logo of banned media), trademark

qrcodeLocation

ParameterTypeExampleDescription
xFloat11.0The distance from the left edge of the QR code area to the y-axis. Origin: upper-left corner of the image. Unit: pixels.
yFloat0.0The distance from the top edge of the QR code area to the x-axis. Origin: upper-left corner of the image. Unit: pixels.
wFloat402.0The width of the QR code area. Unit: pixels.
hFloat413.0The height of the QR code area. Unit: pixels.
qrcodeStringhttp://www.aliyundoc.com/0.ZZOliOThe URL that the detected QR code points to.

programCodeData

ParameterTypeExampleDescription
xFloat11.0The distance from the left edge of the mini program code area to the y-axis. Origin: upper-left corner of the image. Unit: pixels.
yFloat0.0The distance from the top edge of the mini program code area to the x-axis. Origin: upper-left corner of the image. Unit: pixels.
wFloat402.0The width of the mini program code area. Unit: pixels.
hFloat413.0The height of the mini program code area. Unit: pixels.

logoData

ParameterTypeExampleDescription
typeStringTVThe type of the detected logo. TV indicates a logo of banned media.
nameStringxxx TVThe name of the detected logo.
xFloat140The distance from the left edge of the logo area to the y-axis. Origin: upper-left corner of the image. Unit: pixels.
yFloat68The distance from the top edge of the logo area to the x-axis. Origin: upper-left corner of the image. Unit: pixels.
wFloat106The width of the logo area. Unit: pixels.
hFloat106The height of the logo area. Unit: pixels.

sfaceData

ParameterTypeExampleDescription
xFloat49The distance from the left edge of the detected face area to the y-axis. Origin: upper-left corner of the image. Unit: pixels.
yFloat39The distance from the top edge of the detected face area to the x-axis. Origin: upper-left corner of the image. Unit: pixels.
wFloat97The width of the detected face area. Unit: pixels.
hFloat131The height of the detected face area. Unit: pixels.
facesJSONArrayThe recognized faces in this area. Each element contains: name (the person's name), rate (confidence score, 0–100), and id (the face ID).

hitLibInfo

ParameterTypeExampleDescription
contextStringHaokanThe custom term matched by the detected text.
libCodeString123456The code of the library containing the matched term.
libNameStringabcThe name of the library containing the matched term.

Examples

Request example

POST http(s)://[Endpoint]/green/image/scan
&<Common request parameters>

{
    "scenes": [
        "porn",
        "terrorism",
        "ad",
        "live",
        "qrcode",
        "logo"
    ],
    "tasks": [
        {
            "dataId": "uuid-xxxx-xxxx-1234",
            "url": "http://www.aliyundoc.com/xxx.jpg"
        }
    ]
}

Response example

{
    "msg": "OK",
    "code": 200,
    "requestId": "69B41AE8-1234-1234-1234-12D395695D2D",
    "data": [
        {
            "msg": "OK",
            "code": 200,
            "dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
            "taskId": "img4wlJcb7p4wH4lAP3111111-123456",
            "url": "http://www.aliyundoc.com/xxx.jpg",
            "extras": {},
            "results": [
                {
                    "scene": "porn",
                    "label": "sexy",
                    "rate": 99.63,
                    "suggestion": "block"
                },
                {
                    "scene": "terrorism",
                    "label": "politics",
                    "rate": 91.54,
                    "suggestion": "block",
                    "sfaceData": [
                        {
                            "x": 49,
                            "y": 39,
                            "w": 97,
                            "h": 131,
                            "faces": [
                                {
                                    "id": "AliFace_0123****",
                                    "name": "Hit name",
                                    "rate": 91.54
                                }
                            ]
                        }
                    ]
                },
                {
                    "scene": "ad",
                    "label": "ad",
                    "rate": 99.91,
                    "suggestion": "block",
                    "extras": {
                        "qrcodes": "http://www.aliyundoc.com/0.ZZOliO",
                        "npx": "72.01",
                        "hitCustomLibCode": "8012345000",
                        "hitCustomLibName": "Name of the custom image library",
                        "hitLibInfo": [
                            {
                                "context": "Hit text",
                                "libCode": "123456",
                                "libName": "Name of the custom text library"
                            }
                        ]
                    },
                    "frames": [
                        {
                            "rate": 89.85,
                            "url": "http://www.aliyundoc.com/xxx-0.jpg"
                        },
                        {
                            "rate": 68.06,
                            "url": "http://www.aliyundoc.com/xxx-1.jpg"
                        }
                    ],
                    "programCodeData": [
                        {
                            "x": 11.0,
                            "y": 0.0,
                            "w": 402.0,
                            "h": 413.0
                        }
                    ]
                },
                {
                    "scene": "live",
                    "label": "drug",
                    "rate": 99.91,
                    "suggestion": "block"
                },
                {
                    "scene": "qrcode",
                    "label": "qrcode",
                    "rate": 99.91,
                    "suggestion": "review",
                    "qrcodeData": [
                        "http://www.aliyundoc.com/01ZZOliO"
                    ]
                },
                {
                    "scene": "logo",
                    "label": "TV",
                    "rate": 99.9,
                    "suggestion": "block",
                    "logoData": [
                        {
                            "name": "xxx TV",
                            "type": "TV",
                            "x": 140,
                            "y": 68,
                            "w": 106,
                            "h": 106
                        }
                    ]
                }
            ]
        }
    ]
}