Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Text Moderation (V3)

Updated on 2024-11-04 GMT+08:00

Function

Moderation (Text) analyzes and identifies whether the uploaded text contains sensitive information and returns the result to you.

NOTE:
  1. Compared with v2, v3 provides enhanced moderation capability and better experience.
  2. Currently, only Chinese content moderation is supported.
  3. By default, the maximum number of concurrent API calls is 50. To increase concurrency, contact Huawei technical support.

Prerequisites

Before using Text Moderation, you need to apply for the service and complete authentication. For details, see Getting Started with Moderation (Text).

URI

POST /v3/{project_id}/moderation/text

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token

Used to obtain the permission to operate APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token.

Enterprise-Project-Id

No

String

Enterprise project ID. Content Moderation allows you to use Enterprise Project Management Service (EPS) to split fees for resources used by different user groups and users. To obtain the enterprise project ID, go to the Enterprise Project Management console, click the enterprise project name, and obtain the enterprise project ID on the enterprise project details page. For how to create an enterprise project, see Content Moderation User Guide.

After an enterprise project is created, parameter transfer involves the following scenarios:

  • If a correct enterprise project ID is carried and Content Moderation can be used properly, the bills will be categorized under the corresponding enterprise project for that ID.
  • If an enterprise project ID that is in the correct format but does not actually exist is carried, and Content Moderation can be used properly, the bills will display the corresponding non-existent enterprise project ID.
  • If no enterprise project ID or an enterprise project ID with incorrect format (such as special characters) is carried, and Content Moderation can be used properly, the bills will be categorized under default.
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

event_type

No

String

Event type. Value options are as follows:

  • nickname
  • title
  • article
  • comment
  • barrage
  • search
  • profile

categories

No

Array of strings

Text moderation scenarios. The options are as follows:

  • terrorism
  • porn
  • ban
  • abuse
  • ad

If this parameter is not specified, all moderation scenarios are included.

data

Yes

TextDetectionDataReq object

Data to be moderated

Table 4 TextDetectionDataReq

Parameter

Mandatory

Type

Description

text

Yes

String

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

Minimum length: 1

Maximum length: 1500

language

No

String

Supported text language. The options are as follows:

  • zh: Chinese
  • en: English
  • ar: Arabic
  • hi: Hindi
  • es: Spanish
  • fr: French
  • ru: Russian
  • pt: Portuguese
  • id: Indonesian
  • de: German
  • ja: Japanese
  • tr: Turkish
  • vi: Vietnamese
  • it: Italian
  • th: Thai
  • tl: Filipino
  • ko: Korean
  • ms: Malay
  • auto: The language type is automatically identified.

The default value is zh. The recommended value is auto, indicating that the system automatically detects the language type.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Unique ID of the request, which is used for troubleshooting. You are advised to save the ID.

Minimum length: 2

Maximum length: 64

result

TextDetectionResult object

Calling result of a successful API call

This parameter is not included for a failed call.

Table 6 TextDetectionResult

Parameter

Type

Description

suggestion

String

Whether the text passes the check.

block: The text contains sensitive information and fails to pass the check.

pass: The text does not contain sensitive information and passes the check.

review: The text needs to be manually reviewed.

label

String

Label of the detection result. The value can be:

  • terrorism: terrorism-related information
  • porn: pornographic information
  • ban: banned information
  • abuse: abuse
  • customized: hit keywords in the custom dictionary

details

Array of TextDetectionResultDetail objects

Detection details

Table 7 TextDetectionResultDetail

Parameter

Type

Description

suggestion

String

Whether the text passes the check.

block: The text contains sensitive information and fails to pass the check.

pass: The text does not contain sensitive information and passes the check.

review: The text needs to be manually reviewed.

label

String

Label of the detection result.

The value can be:

  • terrorism: terrorism-related information
  • porn: pornographic information
  • ban: banned information
  • abuse: abuse
  • customized: hit keywords in the custom dictionary

confidence

Float

Confidence. The value ranges from 0 to 1. A larger value indicates a higher confidence.

segments

Array of Segment objects

Hit risky segments. If a semantic algorithm model is hit, an empty list is returned.

Table 8 Segment

Parameter

Type

Description

segment

String

Hit risk segment

glossary_name

String

Name of the hit custom word dictionary.

This field is returned only when a custom word dictionary is hit.

position

Array of integers

Position of the hit risky segment in the text. The position starts from 0.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Error message of a failed API call.

This parameter is not included when the API is successfully called.

Example Request

NOTE:

endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.

For example, if the service is deployed in the CN North-Beijing4 region, the endpoint is moderation.cn-north-4.myhuaweicloud.com and the request URL is https://moderation.cn-north-4.myhuaweicloud.com/v3/{project_id}/moderation/text. For details about how to obtain the project ID, see Obtaining a Project ID.

  • The following is an example request for checking whether the text contains sensitive content. The event type is comment and the detection text is asdfasdfasdf.
    POST https://{endpoint}/v3/{project_id}/moderation/text
    {
      "event_type" : "comment",
      "data" : {
        "text" : "asdfasdfasdf"
      }
    }

Example Response

Status code: 200

Example successful response
{
  "request_id" : "58e7d9c7-3456-4ba1-80df-6f25506bc4df",
  "result" : {
     "suggestion" : "block",
     "label" : "customized",
     "details" : [ {
        "suggestion" : "block",
        "label" : "customized",
        "confidence" : 1,
        "segments" : [ {
            "segment" : "xxx",
            "glossary_name" : "zzz"
       } ]
     } ]
   }
}

Status code: 400

Example failed response
{
  "error_code" : "AIS.0011",
  "error_msg" : "Lack the request parameter, or the request parameter is empty."
}

Status Codes

Status Code

Description

200

Example of a successful response

400

Example of a failed response

Error Codes

For details, see Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback