Updated on 2025-07-04 GMT+08:00

Moderation

The moderation connector is used to connect to the Huawei Cloud Content Moderation.

Content Moderation adopts image, text, and video moderation technologies that detect pornography, advertisements, and material related to terrorism. This reduces potential business risks.

Creating a Content Moderation Connection

  1. Log in to the new ROMA Connect console.
  2. In the navigation pane on the left, choose Connector. On the page displayed, click New Connection.
  3. Select the content moderation connector.
  4. In the dialog box displayed, configure the connector and click OK.

    Parameter

    Description

    Name

    Enter the connector instance name.

    App Key

    Access key ID (AK) of the current account. Obtain the AK by referring to Access Keys. If an AK/SK pair has been generated, find the downloaded AK/SK file (such as credentials.csv).

    App Secret

    Secret access key (SK) of the current account. Obtain the SK by referring to Access Keys. If an AK/SK pair has been generated, find the downloaded AK/SK file (such as credentials.csv).

    Description

    Enter the description of the connector to identify it.

Action

  • Audio content moderation
  • Task submission
  • Job list query
  • Result query
  • Image moderation
  • Text moderation

Configuration Parameters

Table 1 Audio content moderation

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

data

This parameter and url are alternative.

Base64 character string converted from the audio file. The size cannot exceed 4 MB. The audio duration cannot exceed 1 minute.

url

This parameter and data are alternative.

URL of the audio file. Currently, URLs for temporarily authorized access and anonymously and publicly authorized access to audio files stored on OBS are supported. For details about how to set the OBS access permission, see Configuring the Access Permission of OBS. For security purposes, the current service cannot obtain data from any URL on the public network.

config

Audio file configuration.

format

Supported audio formats.

  • pcm16k16bit
  • pcm8k16bit
  • ulaw16k8bit
  • ulaw8k8bit
  • alaw16k8bit
  • alaw8k8bit
  • mp3
  • aac
  • wav
  • amr
  • amrwb

property

Model feature string in use. Generally, the value is in the language_sampling rate_domain format. The sampling rate must be the same as that of the audio.

The model feature string can be chinese_8k_common and chinese_16k_common.

categories

Supported categories:

  • Default: politics, porn, ad, abuse, and contraband.
  • Custom: custom word dictionary.
Table 2 Task submission

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

urls

Image URL. Currently, the following URLs are supported:

  • HTTP/HTTPS URLs on the public network
  • Huawei Cloud OBS URLs. To use OBS data, authorization is required, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.

You can configure a maximum of 500 URLs. The API response time depends on the image download time. If the image download takes a long time, the API call will fail. Ensure that the storage service where the image to be detected resides is stable and reliable. You are advised to use Huawei Cloud OBS.

categories

Detection scenarios.

  • politics: checks whether political figures exist.
  • terrorism: checks whether any sensitive person involved in political affairs, terrorism-related content, or sensitive political information exists.
  • porn: checks whether pornographic elements exist.

You can set the parameter to the preceding values to check the corresponding elements.

If this parameter is null or unavailable, politics and terrorism (excluding porn) are detected by default.

moderation_rule

Name of the moderation rule. The default rule is used by default.

ad_categories

Image and text moderation scenario. This parameter is valid only when the value of categories contains ad.

The following scenarios are supported:

  • System-defined scenario:
    • qr_code: The image contains a QR code.
    • politics: The image contains sensitive political information.
    • porn: The image contains pornographic information.
    • ad: The image contains advertisement-related elements.
    • abuse: The image contains offensive content.
    • contraband: The image contains contraband information.
  • User-defined scenario: custom blacklist dictionary

show_ocr_text

Whether to return the OCR recognition result.

  • true: Return the OCR recognition result.
  • false: Not return the OCR recognition result.
Table 3 Job list query

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

status

Job status. Possible values are as follows:

  • created: indicates that a job is created.
  • running: indicates that a job is being processed.
  • finish: indicates that a job is completed.
  • failed: indicates that a job fails.

offset

Offset. The default value is 0.

limit

Maximum number of records returned on each page. The default value is the number of jobs that meet the search criteria.

Table 4 Result query

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

job_id

Job ID.

Table 5 Image moderation

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

urls

This parameter and image are alternative.

Image URL. Currently, the following URLs are supported:

  • HTTP/HTTPS URLs on the public network
  • Huawei Cloud OBS URLs. To use OBS data, authorization is required, including service authorization, temporary authorization, and anonymous public authorization. For details, see Configuring the Access Permission of OBS.

The API response time depends on the image download time. If the image download takes a long time, the API call will fail. Ensure that the storage service where the image to be detected resides is stable and reliable. You are advised to use Huawei Cloud OBS.

image

This parameter and url are alternative.

Indicates the Base64 character string converted from the image. The size cannot exceed 10 MB.

The face of a political figure must contain at least 50 × 50 pixels.

JPEG, PNG, BMP, WEBP, and GIF formats are supported.

moderation_rule

Name of the moderation rule. The default rule is used by default.

categories

Detection scenarios.

  • politics: checks whether political figures exist.
  • terrorism: checks whether terrorism-related content or sensitive political information exists.
  • porn: checks whether pornographic elements exist.
  • ad: checks whether advertisements exist (in the open beta test).
  • all: checks the politics, terrorism, and porn scenarios.

You can set the parameter to the preceding values to check the corresponding elements.

If this parameter is left blank or does not exist, both politics and terrorism scenarios are checked, but the porn scenario is not included.

The number of detection times in each scenario is calculated by category.

ad_categories

Image and text moderation scenario. This parameter is valid only when the value of categories contains ad.

The following scenarios are supported:

  • System-defined scenario:
    • qr_code: The image contains a QR code.
    • politics: The image contains sensitive political information.
    • porn: The image contains pornographic information.
    • ad: The image contains advertisement-related elements.
    • abuse: The image contains offensive content.
    • contraband: The image contains contraband information.
  • User-defined scenario: custom blacklist dictionary

threshold

  • Threshold for filtering the detection results. Only the results whose confidence score is no less than the threshold are displayed in the detail list. The value ranges from 0 to 1. If this parameter is left unspecified, the default values of different scenarios are used.
  • The default value of the politics scenario is 0.95.
  • The default value of the terrorism scenario is 0.
  • The default value of the ad scenario is 0.
  • If there is no special requirement, do not pass this parameter, or leave this parameter unspecified as shown in the example request.
  • If the maximum confidence score of a specific detection scenario is smaller than the value of threshold, the detail list is empty. If the value of threshold is too small, too many results are displayed in the detail list.
  • The threshold parameter does not support filtering of the porn scenario.
  • The threshold parameter does not affect the suggestion in the response.

show_ocr_text

Whether to return the OCR recognition result.

  • true: Return the OCR recognition result.
  • false (default): Not return the OCR recognition result.
Table 6 Text moderation

Parameter

Description

project_id

Project ID, which is used for resource isolation.

region_id

Region ID.

categories

Detection scenarios.

The following scenarios are supported:

  • Default
    • politics: Contains sensitive political information.
    • porn: Contains pornographic information.
    • ad: Contains advertisement-related elements.
    • abuse: Contains offensive content.
    • contraband: Contains contraband information.
    • flood: Contains spamming content.
  • User-defined scenario: custom blacklist dictionary Custom whitelist dictionaries cannot be used in the flood scenario.

white_glossaries

Whitelist that is enabled. The rules for using whitelists are as follows:

  • If this parameter is not transferred, whitelist word dictionaries created before 2022-09-02 16:00:00 are used.
  • If this parameter is transferred:
    • Null: No whitelist word library is used.
    • Non-null: The input whitelist word library is used.

items

Text items to be checked. Currently, only one item can be checked each time.

text

Text to be detected. The text is encoded using UTF-8. A maximum of 5,000 characters are allowed. If the text contains more than 5,000 characters, only the first 5,000 characters are detected.

type

Text type. The default value is content. Currently, only this value is supported.