This topic describes how to use the multi-modal content moderation API to detect risky or non-compliant content in media that combines images and text.
Use cases
Alibaba Cloud Content Moderation provides a multimodal moderation service powered by a large model to analyze content that combines images and text. The service more effectively detects risk content by examining images, associated text, and their context. The following use cases are supported:
Analyze posts and comments: In community forums and discussion boards, the service comprehensively assesses risks by analyzing the main post and its associated comments. A main post includes a title, body text, and images. Comments include text and images, and support nested replies. The service evaluates all these elements together to detect risk content.
Analyze user profiles: For applications such as social media, instant messaging (IM), and gaming, the service performs a comprehensive risk analysis on user profiles. It combines a user's avatar (image) and nickname (text) to determine if they constitute risk content.
Services
The multimodal content moderation feature supports the following services:
Service | Description | Use cases |
Service Name: post_text_image_detection Service: post_text_image_detection | Analyzes the main post and its comments to provide a comprehensive risk assessment. This service detects various risks, including politically sensitive content, pornographic content, suggestive content, inappropriate content, spam, abusive language, terrorism-related content, and prohibited content. | Ideal for platforms with high volumes of user-generated content, such as online communities and forums. It provides a comprehensive risk assessment by analyzing post text, images, and context. |
Service Name: profile_text_image_detection Service: profile_text_image_detection | Analyzes a user's profile picture and nickname to provide a comprehensive risk assessment. This service detects various risks, including politically sensitive content, pornographic content, suggestive content, inappropriate content, spam, abusive language, terrorism-related content, and prohibited content. | Ideal for any platform with user profiles, such as social media, instant messaging (IM), gaming, e-commerce, and education platforms. |
Billing
The AIGC detection service for Image-Text Hybrid Moderation Enhanced Edition supports two billing methods: pay-as-you-go and resource package deduction.
Pay-as-you-go
After you activate the Image-Text Hybrid Moderation Enhanced Edition service, pay-as-you-go is the default billing method. You are charged daily based on your actual usage. You incur no fees if you do not use the service.
Moderation type | Supported business scenarios (services) | Unit price |
Qwen-powered Large Model for Image Moderation (image_vl_standard) |
| CNY 45.00 per 10,000 images Note Billing is based on the number of processed images. For example, if you submit 10 images, the fee is CNY 0.045. |
General Large Model for Text Moderation (text_llm_standard) | CNY 20.00 per 10,000 calls Note Billing is based on the number of characters submitted in each API call. Each block of 1,000 characters counts as one call. If the text exceeds 1,000 characters, the number of calls is rounded up. For example, a single API call with 3,500 characters counts as 4 calls and costs CNY 0.008. |
The billing frequency for the pay-as-you-go Content Moderation Enhanced Edition is once per hour. In the billing details, moderationType corresponds to the moderation type field. You can view the Billing Details.
Resource package deduction
If you have a large or consistent volume of content to moderate, we recommend that you purchase a resource package in advance. Larger packages provide greater discounts, and you can stack multiple packages. For more details, see Purchase a resource plan for Content Moderation Pro.
This resource package covers usage for Content Moderation Enhanced Edition and cannot be shared with traffic packages for Content Moderation 1.0. The deduction factors are as follows:
Moderation type | Deduction factor |
Qwen-powered Large Model for Image Moderation (image_vl_standard) | 6 calls per image: Processing one image deducts 6 calls from your resource package. Note For example, if your resource package has a capacity of 10 calls, processing one image deducts 6 calls, leaving a balance of 4 calls. |
General Large Model for Text Moderation (text_llm_standard) | 2.67 calls per 1,000 characters: Processing each 1,000-character block of text deducts 2.67 calls from your resource package. Note For example, if your resource package has a capacity of 10 calls, processing 900 characters of text deducts 2.67 calls, leaving a balance of 7.33 calls. |
After you purchase a resource package, the system first deducts usage for the Image-Text Hybrid Moderation Enhanced Edition API from your package. If the balance in your resource package is insufficient, the system automatically switches to pay-as-you-go billing. We recommend that you monitor your package balance and pay-as-you-go bills. You can set up low-balance alerts on the Resource Plan page within Alibaba Cloud Billing Management.
Getting started
Sign up for an Alibaba Cloud account. If you do not have an account, register now.
To activate pay-as-you-go for Content Moderation, make sure that you have activated the service. For more information, see Activate Service. Activation is free of charge. After you start to use the API, the system automatically generates bills based on your usage. For more information, see Billing (to be determined). You can also purchase pay-as-you-go resource packages. Compared to the standard postpaid method, resource packages offer tiered discounts and are suitable for users with predictable and high usage. For more information, see Purchase Pay-as-you-go Resource Package.
Create an AccessKey: Ensure that you have created an AccessKey by using RAM. For more information, see Create an AccessKey. If you are using the AccessKey of a RAM user (sub-account), you must use an Alibaba Cloud account (main account) to grant the AliyunYundunGreenWebFullAccess permission to the RAM user. For more information, see RAM Authorization.
Integrate the service by using an SDK, the recommended method for making API calls. See the Multimodal Content Moderation SDK and Integration Guide.
Submit a moderation task
API
API operation:
MultimodalAsyncModeration.Supported regions and endpoints:
Region | Public endpoint | Internal endpoint |
China (Shanghai) | https://green-cip.cn-shanghai.aliyuncs.com | https://green-cip-vpc.cn-shanghai.aliyuncs.com |
Billing: This is a paid API. You are charged based on the number of submitted images and the character count of the text. For more information, see Billing.
Detection object: The service detects text and image content.
Response: This is an asynchronous operation. Results are not returned in real time. You can retrieve them through a callback or by polling. The results are retained for up to 24 hours.
Callback: To automatically receive detection results, specify the callback parameter in your request.
Polling: If you do not specify the callback parameter, you must call the result query API to retrieve the detection results.
Data Requirements:
The total text length cannot exceed 5,000 characters, and the total number of images cannot exceed 30.
Supported image formats: PNG, JPG, JPEG, BMP, WEBP, TIFF, SVG, HEIC (the longest side of an HEIC image must be less than 8,192 pixels), GIF (only the first frame is processed), and ICO (only the last image is processed).
The image size cannot exceed 20 MB. The height or width cannot exceed 16,384 pixels, and the total number of pixels cannot exceed 167 million. We recommend a minimum resolution of 200 x 200 pixels. Low resolution may reduce moderation accuracy.
The image download is limited to 3 seconds. A download that exceeds this limit returns a timeout error.
QPS limits
Each Alibaba Cloud account is limited to 10 QPS for this API. Exceeding this limit results in throttling, which can affect your services. Plan your calls accordingly.
Request parameters
Parameter | Type | Required | Example value | Description |
Service | String | Yes | post_text_image_detection | The moderation service type. Valid values:
|
ServiceParameters | JSONString | Yes | The moderation service parameters, formatted as a JSON string. For details, see ServiceParameters. |
Table 1. ServiceParameters
Parameter | Type | Required | Example value | Description | ||
mainData | Array | Yes | The main content to moderate, such as a post or a user profile. For more information, see mainData. | |||
commentDatas | Array | No | The comments to moderate. This parameter is applicable only to post moderation scenarios. For more information, see commentDatas. | |||
dataId | String | No | Multimodal**** | The data ID for the moderation object. The data ID can contain letters, digits, underscores (_), hyphens (-), and periods (.), and must be no more than 128 characters long. Use the data ID to uniquely identify your business data. | ||
Table 2. mainData
Parameter | Type | Required | Example value | Description |
mainTitle | String | No | This is a title | The main title or user profile description to moderate. The total length cannot exceed 5,000 characters. |
mainContent | String | Yes | This is the main content | The main text or nickname to moderate. |
mainImages | Array | Yes | The main images or user avatar to moderate. The total number of images cannot exceed 30. For details, see mainImages. | |
mainPostTime | DateTime | No | 2025-06-18 20:20:20 | The time when the main post was published. |
Table 3. mainImages
Parameter | Type | Required | Example value | Description |
imageUrl | String | Yes. You can provide an image in one of the following two ways:
| http://www.aliyundoc.com/a.jpg | The URL of the object to moderate. It must be publicly accessible and no more than 2,048 characters long. |
ossBucketName | String | bucket_01 | The name of the authorized OSS bucket. Note To use an internal OSS endpoint, you must first use your main Alibaba Cloud account to authorize access on the Cloud Resource Access Authorization page. | |
ossObjectName | String | 2023/04/24/test.jpg | The object name in the authorized OSS bucket. | |
ossRegionId | String | cn-beijing | The region where the OSS bucket is located. |
Table 4. commentDatas
Parameter | Type | Required | Example value | Description |
content | String | Yes | This is the comment text | The comment text to moderate. The text cannot exceed 1,000 characters in length. |
images | Array | No | The images in the comment to moderate. The number of images cannot exceed 10. For more information, see images. | |
postTime | DateTime | No | 2025-06-18 20:20:20 | The time when the comment was published. |
commentDatas | Array | The nested comments (replies) to moderate. For more information, see commentDatas. |
Table 5. images
Parameter | Type | Required | Example value | Description |
imageUrl | String | No. If you include images, you must provide them in one of the following two ways:
| http://www.aliyundoc.com/a.jpg | The URL of the object to moderate. The URL must be publicly accessible and cannot exceed 2,048 characters in length. |
ossBucketName | String | bucket_01 | The name of the authorized OSS bucket. Note To use an internal OSS endpoint, you must first use your main Alibaba Cloud account to authorize access on the Cloud Resource Access Authorization page. | |
ossObjectName | String | 2023/04/24/test.jpg | The object name in the authorized OSS bucket. | |
ossRegionId | String | cn-beijing | The region where the OSS bucket is located. |
Table 6. commentDatas
Parameter | Type | Required | Example value | Description |
content | String | Yes | This is the comment text | The comment text to moderate. The text cannot exceed 1,000 characters in length. |
images | Array | No | The images in the comment to moderate. The number of images cannot exceed 10. For more information, see images. | |
postTime | DateTime | No | 2025-06-18 20:20:20 | The time when the comment was published. |
Response parameters
Parameter | Type | Example value | Description | |
Code | Integer | 200 | The status code. This is consistent with an HTTP status code. For details, see Status codes. | |
Data | JSONObject | {"ReqId": "AAAAA-BBBBB-AIXI-1314-CCCCC"} | The data returned for the request. The value is the task ID. | |
DataId | String | Multimodal0424*** | The data ID that corresponds to the moderated object. Note: If you specified the dataId request parameter, this parameter is returned with the same value. | |
Message | String | OK | The response message. | |
RequestId | String | ABCD1234-1234-1234-1234-123**** | The request ID. | |
Examples
Request Example
Submit text and image content
{
"service": "post_text_image_detection",
"serviceParameters": {
"dataId": "Multimodal0424***",
"mainData": {
"mainTitle": "This is a title or user profile",
"mainContent": "This is the main text or user nickname",
"mainImages": [
{
"imageUrl": "https://aliyun.com/240308/test001.jpg"
},
{
"imageUrl": "https://aliyun.com/240308/test002.jpg"
}
],
"mainPostTime": "2025-06-18 20:20:20"
},
"commentDatas": [
{
"images": [
{
"imageUrl": "https://aliyun.com/240308/test003.jpg"
},
{
"imageUrl": "https://aliyun.com/240308/test004.jpg"
}
],
"content": "Comment 1",
"postTime": "",
"commentDatas": [
{
"content": "Reply 1 to Comment 1",
"images": [
{
"imageUrl": "https://aliyun.com/240308/test005.jpg"
}
],
"postTime": ""
},
{
"content": "Reply 2 to Comment 1",
"images": [
{
"imageUrl": "https://aliyun.com/240308/test006.jpg"
}
],
"postTime": ""
}
]
},
{
"content": "Comment 2",
"images": [],
"postTime": "",
"commentDatas": []
},
{
"content": "Comment 3",
"images": [],
"postTime": "",
"commentDatas": []
},
{
"content": "Comment 4",
"images": [],
"postTime": "",
"commentDatas": []
},
{
"content": "Comment 5",
"images": [],
"postTime": "",
"commentDatas": []
},
{
"content": "Comment 6",
"images": [],
"postTime": "",
"commentDatas": []
},
{
"content": "Comment 7",
"images": [],
"postTime": "",
"commentDatas": []
}
]
}
}Response Example
{
"Code": 200,
"Data": {
"DataId": "Multimodal0424***",
"TaskId": "task_1713942548822_1t4qI8"
},
"Message": "OK",
"RequestId": "AAAAA-BBBBB-AIXI-1314-CCCCC"
}Retrieve multimodal moderation results
API
API operation: DescribeMultimodalModerationResult. This operation retrieves the results of a multimodal moderation task.
Billing: This API is free of charge.
Polling for results: We recommend polling for results every 30 seconds, starting 30 seconds after you submit an asynchronous detection task. The results are retained for up to 24 hours and then automatically deleted.
QPS limit
The QPS limit for this API is 10 for each Alibaba Cloud account. If you exceed this limit, the system throttles your API calls. This may affect your services. Plan your calls accordingly.
Request parameters
Parameter | Type | Required | Example value | Description |
ReqId | String | Yes | AAAAA-BBBBB-AIXI-1314-CCCCC | The TaskId of the asynchronous detection task to query. Note You can obtain the TaskId from the response when you submit an asynchronous detection task. |
Response parameters
Parameter | Type | Example value | Description |
RequestId | String | ABCD1234-1234-1234-1234-123**** | A unique identifier for the request, generated by Alibaba Cloud for troubleshooting. |
Data | Object | The multimodal moderation results. For more information, see Data. | |
Code | String | 200 | The status code, which is consistent with HTTP status codes. For more information, see Code Description. |
Message | String | OK | The message associated with the response. |
Table 2. Data
Parameter | Type | Example value | Description |
DataId | String | Multimodal0424*** | The data ID that corresponds to the moderated object. Important If you specified the DataId in the request, this parameter is returned with the same value. |
RiskLevel | String | The risk level of the entire post. Valid values include:
| |
MainData | JSONArray | The moderation results for the main post. For more information, see MainData. | |
CommentDatas | JSONArray | The moderation results for the comments. The response structure corresponds to the input structure. For more information, see CommentDatas. | |
Usage | Object | Statistics about token usage. For more information, see Usage. |
Table 3. MainData
Parameter | Type | Example value | Description |
Result | JSONArray | The moderation result. For more information, see Result. |
Table 4. Result
Parameter | Type | Example value | Description |
Label | String | violent_explosion | The risk label. |
Description | String | Content may contain elements related to fireworks. | A description of the Label. Important This field explains the Label. Because this description may change, we recommend building your logic around the Label value instead of this description. |
Table 5. CommentDatas
Parameter | Type | Example value | Description |
Result | JSONArray | The moderation result of the comment. For more information, see Result. | |
CommentDatas | JSONArray | The nested moderation results for replies. For more information, see CommentDatas (nested). |
Table 6. CommentDatas (nested)
Parameter | Type | Example value | Description |
Result | JSONArray | The moderation result of the comment. For more information, see Result. |
Table 7. Usage
Parameter | Type | Example value | Description |
Total_tokens | Integer | 1039 | The total number of tokens consumed. |
Output_tokens | Integer | 56 | The number of tokens in the response. |
Input_tokens | Integer | 983 | The number of tokens in the request. |
Examples
Sample request
{
"ReqId": "AAAAA-BBBBB-AIXI-1314-CCCCC"
}Sample responses
Non-compliant content detected
{
"RequestId": "ABCD1234-1234-1234-1234-123****",
"Message": "OK",
"Code": 200,
"Data": {
"DataId": "dataId***",
"RiskLevel": "high",
"MainData": {
"Result": [
{
"Label": "violent_explosion",
"Description": "Content may contain elements related to fireworks."
},
{
"Label": "sexual_partialNudity",
"Description": "Suggestive content"
}
]
},
"CommentDatas": [
{
"Result": [
{
"Label": "violent_explosion",
"Description": "Content may contain elements related to fireworks."
},
{
"Label": "sexual_partialNudity",
"Description": "Suggestive content"
}
],
"CommentDatas": [
{
"Result": [
{
"Label": "violent_explosion",
"Description": "Content may contain elements related to fireworks."
},
{
"Label": "violent_explosion",
"Description": "Content may contain elements related to fireworks."
}
]
},
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
}
]
},
{
"Result": [
{
"Label": "violent_explosion",
"Description": "Content may contain elements related to fireworks."
}
]
},
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
}
],
"Usage": {
"Total_tokens": 1039,
"Output_tokens": 56,
"Input_tokens": 983
}
}
}No non-compliant content detected
{
"RequestId": "ABCD1234-1234-1234-1234-123****",
"Message": "OK",
"Code": 200,
"Data": {
"DataId": "dataId***",
"RiskLevel": "none",
"MainData": {
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
},
"CommentDatas": [
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
],
"CommentDatas": [
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
},
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
}
]
},
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
},
{
"Result": [
{
"Label": "nonLabel",
"Description": "No non-compliant content detected"
}
]
}
],
"Usage": {
"Total_tokens": 1039,
"Output_tokens": 56,
"Input_tokens": 983
}
}
}Code
This topic describes the code values returned by the multimodal content moderation API. Metering and billing apply only to requests that return a code of 200 or 280. You are not charged for requests with other code values.
| Description |
200 | The request is successful. |
280 | The moderation task is in progress. |
400 | A required request parameter is missing or empty. |
401 | A request parameter is invalid. |
402 | A request parameter exceeds the length limit. Check the parameter and resubmit the request. |
408 | The account does not have permission to call this API. This can occur if the service is not activated, the account is overdue, or required permissions are missing. |
500 | An internal system error occurred. |