API overview
The Image Moderation 2.0 API detects images that violate content regulations, disrupt platforms, or degrade user experience. It supports 40+ risk labels and 40+ risk controls. Image Moderation 2.0 returns risk labels and confidence scores for reviewing or moderating images per your platform policies. Image Moderation Pro 2.0: Overview and Billing.
Getting started
Sign up for an Alibaba Cloud account: Register.
Activate pay-as-you-go for Content Moderation: Activate the service. Activation is free, and usage is billed automatically (billing).
Create an AccessKey: Use RAM to create an AccessKey. If you use a RAM user's AccessKey, grant the
AliyunYundunGreenWebFullAccesspermission to the RAM user from your Alibaba Cloud account. RAM authorization.Integrate using an SDK. Image Moderation - Enhanced (2.0) SDK and integration guide.
Usage notes
This API creates an image content moderation task. You can construct requests by following the HTTP Native Call guide, or use the pre-built examples in the Access Guide.
API operation: ImageModeration
Supported regions and endpoints:
Region
Public endpoint
VPC endpoint
Supported service codes
Singapore
green-cip.ap-southeast-1.aliyuncs.com
green-cip-vpc.ap-southeast-1.aliyuncs.com
postImageCheckByVL_global、baselineCheck_global、aigcDetector_global、faceDetect_global、faceDetect_pro_global
Malaysia (Kuala Lumpur)
green-cip.ap-southeast-3.aliyuncs.com
None
Indonesia (Jakarta)
green-cip.ap-southeast-5.aliyuncs.com
None
UK (London)
green-cip.eu-west-1.aliyuncs.com
None
China (Hong Kong)
green-cip.cn-hongkong.aliyuncs.com
green-cip-vpc.cn-hongkong.aliyuncs.com
postImageCheckByVL_global
US (Virginia)
green-cip.us-east-1.aliyuncs.com
green-cip-vpc.us-east-1.aliyuncs.com
baselineCheck_global、aigcDetector_global
US (Silicon Valley)
green-cip.us-west-1.aliyuncs.com
None
Germany (Frankfurt)
green-cip.eu-central-1.aliyuncs.com
green-cip-vpc.eu-central-1.aliyuncs.com
The endpoint that you specify in an API call determines where Content Moderation downloads and moderates the image. The region where you activate the service in the console does not determine the moderation location. For example, if you call
green-cip.us-west-1.aliyuncs.com, Content Moderation downloads and moderates images in the US (Silicon Valley) region. Select an endpoint that is close to your application servers to reduce network latency.The Image Moderation 2.0 API uses the endpoint format
green-cip.{regionId}.aliyuncs.com, such asgreen-cip.cn-shanghai.aliyuncs.com. Do not call this API at the Content Moderation 1.0 configuration endpointgreen.{regionId}.aliyuncs.com. Otherwise, the request fails.The UK (London), Malaysia (Kuala Lumpur), and Indonesia (Jakarta) regions reuse the console configuration of the Singapore region. The US (Silicon Valley) region reuses the console configuration of the US (Virginia) region.
Global Edition services (with the
_cbsuffix, such asbaselineCheck_cb) are deployed in international regions such as Singapore and the US for overseas image moderation scenarios. Calling a Global Edition endpoint from the Chinese mainland goes through cross-border network links and incurs significantly higher latency than calling a China region. If your business mainly serves users in the Chinese mainland, call the corresponding standard service in a China region, for example, the China (Shanghai) endpointgreen-cip.cn-shanghai.aliyuncs.com.Billing:
Billable. Only requests with HTTP status code 200 are charged; failed requests are not billed. This API supports multi-scenario detection in a single request through the Multi-Service Synchronous Detection API. Specify only the
Servicevalues required for your business scenario rather than a fixed full set of checks. EachServicedetected in a request is billed separately at its own price. Billing.Image requirements:
Supported formats include PNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, and AVIF. For HEIF images, the longest side cannot exceed 8,192 pixels. For GIFs, only the first frame is processed. For ICO files, only the last image is processed.
The image must not exceed 20 MB. The height or width cannot exceed 30,000 pixels, and the total number of pixels cannot exceed 250 million. For optimal performance, the image resolution should be at least 200 × 200 pixels. Lower resolutions may degrade algorithm performance.
The image must finish downloading within 3 seconds. Otherwise, the request will time out and return an error.
QPS limit
Default limit: 100 QPS per user. Exceeding this limit triggers throttling. To increase the limit, contact your account manager.
Debugging
Debug the Image Moderation API online through Alibaba Cloud OpenAPI before integrating into your application. The portal provides code examples, SDK dependencies, and parameter documentation.
Debugging calls use your account and count toward billed usage.
Request parameters
For cURL calls and native HTTP request construction, use your AccessKey credentials, include the required common parameters AccessKeyId, Signature, and Timestamp, and calculate the signature. These parameters are required in addition to the business parameters Service and ServiceParameters. If you omit them, the API rejects the request. The clientInfo parameter provides optional business context and is not required. For the full list of required common request parameters, see common parameters.
The request body is a JSON object that contains the following fields:
Parameter | Type | Required | Example | Description |
Service | String | Yes | baselineCheck_global | The image moderation 2.0 service to use. Valid values:
Note For more information about the differences between the services, see Service Description. For AIGC-specific services, see AIGC Scenario Detection Service. The Global Edition can be used only in international regions. Choose a |
ServiceParameters | JSONString | Yes | Content moderation parameters as a JSON string. ServiceParameters. |
Table 1. ServiceParameters
Parameter | Type | Required | Example | Description |
imageUrl | String | Yes. Specify the image by using one of the following three methods:
| https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png | The URL of the image to be moderated. The URL must be publicly accessible and must not exceed 2,048 characters in length. Note
|
ossBucketName | String | bucket_01 | The name of the authorized OSS Bucket. Note To use an internal OSS image URL, you must first grant the AliyunCIPScanOSSRole permission by using your Alibaba Cloud account (root account) on the Cloud Resource Access Authorization page. Even when you submit an image by using OSS authorization, Content Moderation may retrieve the original image URL to verify the authenticity and accessibility of the image. If the origin server returns HTTP 403 because of hotlink protection, add the documented Content Moderation service domain or IP range to the hotlink protection whitelist, or temporarily disable hotlink protection for testing. Do not rely only on the wildcard | |
ossObjectName | String | 2022023/04/24/test.jpg | The name of the object in the authorized OSS Bucket. Note 1. Specify the original OSS object name. Appending image processing parameters to the name is not supported. To add image processing parameters, use the imageUrl parameter. 2. If the object name contains Chinese characters or spaces, specify the name as is. Do not URL-encode it. | |
ossRegionId | String | cn-beijing | The region where the OSS Bucket is located. | |
dataId | String | No | img123**** | A unique ID for the object being moderated. Use this ID to track your business data. The ID can be up to 64 characters long and can contain uppercase and lowercase letters, digits, underscores (_), hyphens (-), and periods (.). |
referer | String | No | www.aliyun.com | The |
infoType | String | Yes | customImage,textInImage | The supplementary information to retrieve. Valid values:
You can specify multiple values separated by commas (,). For example, Note Public figure and logo information are returned only for advanced image moderation services. Service Description. |
Returned data
Parameter | Type | Example value | Description |
RequestId | String | 70ED13B0-BC22-576D-9CCF-1CC12FEAC477 | Unique request identifier for troubleshooting. |
Data | Object | Image content moderation result. Data. | |
Code | Integer | 200 | Status code. Code Description. |
Msg | String | OK | The response message. |
Table 2. Data
Parameter | Type | Example | Description |
Result | Array | The image detection results, including risk labels and confidence scores. For more information, see result. | |
RiskLevel | String | high | The risk level of the image, which is determined by the label with the highest risk. Possible values are:
Note Take immediate action on high-risk content. Manually review medium-risk content. For low-risk content, take action only if a high recall rate is required; otherwise, treat it as risk-free. You can configure risk thresholds in the Content Moderation console. |
DataId | String | img123****** | The unique ID of the data object specified in the request. Note If you provide a DataId in your request, the same value is returned in this field. |
Ext | Object | Extra reference information for the image. For more information, see extra information. |
Table 3. Result
Parameter | Type | Example value | Description |
Label | String | violent_explosion | The label for the detected content. A single image can have multiple labels, each with a corresponding confidence score. For a list of supported labels, see the following: Note For labels related to the Content Moderation LLM service, see the Risk Label Glossary for Content Moderation LLM Service. |
Confidence | Float | 81.22 | The confidence score for the label, on a scale of 0 to 100. The value is accurate to two decimal places. Some labels do not return a confidence score. For more information, see the Risk Label Glossary. |
Description | String | Fireworks-related content | A human-readable explanation of the Important This description is for display purposes only and may change. For automation, rely on the Label field. |
RiskLevel | String | high | The risk level associated with the label, based on your configured thresholds. Possible values:
|
Examples
Request example
{
"Service": "baselineCheck_global",
"ServiceParameters": {
"imageUrl": "https://img.alicdn.com/tfs/TB1U4r9AeH2gK0jSZJnXXaT1FXa-2880-480.png",
"dataId": "img123****"
}
}Response example
Response when risk content is detected
{ "Msg": "OK", "Code": 200, "Data": { "DataId": "img123****", "Result": [ { "Label": "pornographic_adultContent", "Confidence": 81, "Description": "Adult Content" }, { "Label": "sexual_partialNudity", "Confidence": 98, "Description": "Sexually Suggestive" }, { "Label": "violent_explosion", "Confidence": 70, "Description": "Explosion" }, { "Label": "violent_explosion_lib", "Confidence": 81, "Description": "Explosion (Custom Library)" } ], "RiskLevel": "high" }, "RequestId": "ABCD1234-1234-1234-1234-1234XYZ" }Response when no risk content is detected
{ "Msg": "OK", "Code": 200, "Data": { "DataId": "img123****", "Result": [ { "Label": "nonLabel", "Description": "No Risk Detected" } ], "RiskLevel": "none" }, "RequestId": "ABCD1234-1234-1234-1234-1234XYZ" }
Response when an image matches the image allowlist
{ "Msg": "OK", "Code": 200, "Data": { "DataId": "img123****", "Result": [ { "Label": "nonLabel_lib", "Confidence": 83, "Description": "Matched in Image Allowlist" } ], "RiskLevel": "none" }, "RequestId": "ABCD1234-1234-1234-1234-1234XYZ" }
Examples are formatted for readability. Actual responses are single-line strings without line breaks or indentation.
Risk labels
The following tables list risk labels, their meanings, and confidence score ranges. You can toggle labels and configure detection scopes in the Console Operation Guide. Supported labels by service:
Scenario | Services and labels |
General scenario | |
AIGC scenario |
For labels returned when no risk is detected or an image matches the image whitelist, see Supported labels for no-risk or whitelisted images.
We recommend storing the risk labels and confidence scores returned by the system for content governance. Use them to prioritize manual review, annotation, and implement tiered and categorized governance measures.
Table 4. Supported tags for general baseline detection (baselineCheck_global)
Label | Confidence score | Description |
pornographic_adultContent | A score from 0 to 100. A higher score means greater confidence. | The image may contain adult pornographic content. |
pornographic_cartoon | A score from 0 to 100. A higher score means greater confidence. | The image may contain pornographic cartoon content. |
pornographic_adultToys | A score from 0 to 100. A higher score means greater confidence. | The image may contain adult toys. |
pornographic_art | A score from 0 to 100. A higher score means greater confidence. | The image may contain pornographic art. |
pornographic_adultContent_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains pornographic content. |
pornographic_suggestive_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains suggestive content. |
pornographic_o_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains special category content. For more information, see the Content Moderation console. |
pornographic_organs_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains descriptions of sexual organs. |
pornographic_adultToys_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains content related to adult toys. |
sexual_suggestiveContent | A score from 0 to 100. A higher score means greater confidence. | The image may contain vulgar or sexually suggestive content. |
sexual_femaleUnderwear | A score from 0 to 100. A higher score means greater confidence. | The image may contain underwear or swimwear. |
sexual_cleavage | A score from 0 to 100. A higher score means greater confidence. | The image may feature female cleavage. |
sexual_maleTopless | A score from 0 to 100. A higher score means greater confidence. | The image may contain topless men. |
sexual_cartoon | A score from 0 to 100. A higher score means greater confidence. | The image may contain sexually suggestive cartoon content. |
sexual_shoulder | A score from 0 to 100. A higher score means greater confidence. | The image may contain sexually suggestive content involving shoulders. |
sexual_femaleLeg | A score from 0 to 100. A higher score means greater confidence. | The image may contain sexually suggestive content involving legs. |
sexual_pregnancy | A score from 0 to 100. A higher score means greater confidence. | The image may contain content related to pregnancy or breastfeeding. |
sexual_feet | A score from 0 to 100. A higher score means greater confidence. | The image may contain sexually suggestive content involving feet. |
sexual_kiss | A score from 0 to 100. A higher score means greater confidence. | The image may contain kissing. |
sexual_intimacy | A score from 0 to 100. A higher score means greater confidence. | The image may contain intimate behavior. |
sexual_intimacyCartoon | A score from 0 to 100. A higher score means greater confidence. | The image may contain intimate behavior in cartoons or animation. |
violent_explosion | A score from 0 to 100. A higher score means greater confidence. | The image may contain elements related to fireworks or explosions. For more information, see the Content Moderation console. |
violent_burning | A score from 0 to 100. A higher score means greater confidence. | The image may contain burning content. |
violent_armedForces | A score from 0 to 100. A higher score means greater confidence. | The image may contain armed forces. |
violent_weapon | A score from 0 to 100. A higher score means greater confidence. | The image may contain weapons. |
violent_crowding | A score from 0 to 100. A higher score means greater confidence. | The image may contain crowds. |
violent_gun | A score from 0 to 100. A higher score means greater confidence. | The image may contain firearms. |
violent_knives | A score from 0 to 100. A higher score means greater confidence. | The image may contain knives. |
violent_horrific | A score from 0 to 100. A higher score means greater confidence. | The image may contain horrific content. |
violent_nazi | A score from 0 to 100. A higher score means greater confidence. | The image may contain Nazi-related content. |
violent_bloody | A score from 0 to 100. A higher score means greater confidence. | The image may contain bloody content. |
violent_extremistGroups_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains content related to terrorist organizations. |
violent_extremistIncident_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains content related to terrorist incidents. |
violence_weapons_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains descriptions of firearms or knives. |
violent_ACU | A score from 0 to 100. A higher score means greater confidence. | The image may contain a combat uniform. |
contraband_drug | A score from 0 to 100. A higher score means greater confidence. | The image may contain drug-related content. |
contraband_drug_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains content related to illicit drugs. |
contraband_gamble | A score from 0 to 100. A higher score means greater confidence. | The image may contain gambling-related content. |
contraband_gamble_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains content related to gambling. |
inappropriate_smoking | A score from 0 to 100. A higher score means greater confidence. | The image may contain smoking-related content. |
inappropriate_drinking | A score from 0 to 100. A higher score means greater confidence. | The image may contain alcohol-related content. |
inappropriate_tattoo | A score from 0 to 100. A higher score means greater confidence. | The image may contain tattoos. |
inappropriate_middleFinger | A score from 0 to 100. A higher score means greater confidence. | The image may contain the middle finger gesture. |
inappropriate_foodWasting | A score from 0 to 100. A higher score means greater confidence. | The image may contain food waste. |
profanity_Offensive_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains severe profanity, verbal attacks, or offensive content. |
profanity_Oral_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains colloquial profanity. |
religion_clothing | A score from 0 to 100. A higher score means greater confidence. | The image may contain special symbols and elements. For more information, see the Content Moderation console. |
religion_logo | A score from 0 to 100. A higher score means greater confidence. | |
religion_flag | A score from 0 to 100. A higher score means greater confidence. | |
religion_taboo1_tii | A score from 0 to 100. A higher score means greater confidence. | The text in the image contains taboo content. For more information, see the Content Moderation console. |
religion_taboo2_tii | A score from 0 to 100. A higher score means greater confidence. | |
flag_country | A score from 0 to 100. A higher score means greater confidence. | The image may contain flag-related content. |
political_historicalNihility | A score from 0 to 100. A higher score means greater confidence. | The image may contain specific content. For more information, see the Content Moderation console. |
political_historicalNihility_tii | A score from 0 to 100. A higher score means greater confidence. | |
political_politicalFigure_1 | A score from 0 to 100. A higher score means greater confidence. | |
political_politicalFigure_2 | A score from 0 to 100. A higher score means greater confidence. | |
political_politicalFigure_3 | A score from 0 to 100. A higher score means greater confidence. | |
political_politicalFigure_4 | A score from 0 to 100. A higher score means greater confidence. | |
political_politicalFigure_name_tii | A score from 0 to 100. A higher score means greater confidence. | |
political_prohibitedPerson_1 | A score from 0 to 100. A higher score means greater confidence. | |
political_prohibitedPerson_2 | A score from 0 to 100. A higher score means greater confidence. | |
political_prohibitedPerson_tii | A score from 0 to 100. A higher score means greater confidence. | |
political_taintedCelebrity | A score from 0 to 100. A higher score means greater confidence. | |
political_taintedCelebrity_tii | A score from 0 to 100. A higher score means greater confidence. | |
political_CNFlag | A score from 0 to 100. A higher score means greater confidence. | |
political_CNMap | A score from 0 to 100. A higher score means greater confidence. | |
political_logo | A score from 0 to 100. A higher score means greater confidence. | |
political_outfit | A score from 0 to 100. A higher score means greater confidence. | |
political_badge | A score from 0 to 100. A higher score means greater confidence. | |
pt_logo | A score from 0 to 100. A higher score means greater confidence. | The image may contain a logo. |
QR code | A score from 0 to 100. A higher score means greater confidence. | The image may contain a QR code. |
pt_custom_01 | A score from 0 to 100. A higher score means greater confidence. | Custom label 01. |
pt_custom_02 | A score from 0 to 100. A higher score means greater confidence. | Custom label 02. |
tii is an abbreviation for text in image. A label ending in tii flags non-compliant text.
You can also configure a custom image library for each risk label. If a detected image is a close match to an image in the custom image library, the system returns the corresponding risk label formatted as _lib. For example, if you configure a custom image library for the violent_explosion risk label and a detected image is a close match, the label parameter returns violent_explosion_lib. The corresponding confidence parameter represents the similarity score.
If the system detects no risks in an input image, or if the image is highly similar to an image on your exemption list, the returned label and confidence score are described in the following table.
Label | Confidence score | Description |
nonLabel | This field is not returned. | No risk is detected in the image, or you have disabled all detection items. For more information, see the Content Moderation console. |
nonLabel_lib | A score from 0 to 100. A higher score indicates greater confidence. | The image is highly similar to an image on your exemption list. For more information, see the Content Moderation console. |
Response codes
API response codes. Only requests returning code 200 are billed.
Code | Description |
200 | The request was successful. |
400 | The request parameters are empty. |
401 | The request parameters are invalid. |
402 | A request parameter has an invalid length. Check the parameter and retry the request. |
403 | The request rate exceeds the QPS limit. Check and adjust your concurrency. |
404 | Failed to download the image due to an error or timeout. Verify the image URL and try again. |
405 | The image download timed out, possibly because the image is inaccessible. Check its access settings and try again. |
406 | The input image is too large. Reduce the image size and try again. |
407 | The input image format is not supported. Convert the image and try again. |
408 | Permission to call this API was denied. This can occur if the service is not activated, the account has an overdue payment, or the account lacks authorization. |
500 | A system error occurred. |
FAQ
Do I need to manually extract images from a web page before calling this operation for image moderation?
No. You only need to provide a publicly accessible URL of the image itself as the imageUrl parameter. The API automatically retrieves the image content from the URL and moderates it, so you do not need to download or extract the image from the web page in advance. If the image is stored in a private bucket, such as an OSS bucket, make sure that Content Moderation is authorized to access that bucket before you call the operation.
Where can I obtain non-compliant sample images to test Content Moderation?
Alibaba Cloud does not provide official test images. Prepare test samples that fit your business scenario, or use publicly available compliant image resources to verify the integration.
How do I resolve a GifParser timeout error?
A GifParser timeout error usually indicates that the image failed to download. First, replace the HTTP image URL with an HTTPS URL and test again. If the error persists, verify that the image URL supports public network access, the file is a standard GIF, and the file size is within the documented limits. Also confirm that the network path to the image works properly.
How do I resolve the InvalidAction.NotFound error code when calling the Image Moderation 2.0 API?
Check the following items:
Set the
x-acs-actionrequest header toImageModerationinstead of the legacyImageSyncScanvalue.Use
/green-cip/v2/image/scanas the URI of the request (request path) instead of/api/v2/image/scanor/v2/image/scan.Calculate the signature with the exact request path, including the
/green-cipprefix.Send the request by using POST and confirm that the Image Moderation 2.0 service is activated.
Use the official Alibaba Cloud software development kit (SDK) when possible. The SDK handles the endpoint, request path, and signature, and helps you avoid errors caused by manual request construction.