Creates a keyword library for use in text anti-spam, ad violation detection, and audio anti-spam moderation.
Operation description
A keyword library stores terms that Content Moderation matches against submitted content. You can create libraries for three moderation scenarios:
Text anti-spam: matches terms against submitted text or detects similar text patterns.
Ad violation detection: matches terms extracted from images.
Audio anti-spam: matches terms converted from audio.
For more information about how to construct an HTTP request, see Request structure. You can also use an existing HTTP client. For more information, see SDK overview.
To create a keyword library in the Alibaba Cloud AI Guardrails console instead of calling this operation, see Manage custom text libraries.
Billing: This operation is free of charge.
QPS limits
This operation is limited to 10 calls per second per account. Exceeding this limit triggers throttling, which may affect your service.
Request parameters
For common request parameters required in all AI Guardrails API requests, see Common parameters.
The following table describes the parameters in the request body.
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| ServiceModule | String | Yes | open_api | The service module name. Set this parameter to open_api. |
| Name | String | Yes | test1sdkdk | The name of the keyword library. |
| ResourceType | String | Yes | TEXT | The moderation scenario for the keyword library. Valid values: <br>- TEXT: text anti-spam <br>- IMAGE: ad violation detection <br>- VOICE: audio anti-spam |
| BizTypes | StringArray | No | ["bizTypeA","bizTypeB"] | The business scenarios to associate with the keyword library. To get business scenario names, call the CreateBizType operation. |
| Category | String | Yes | BLACK | The category of the keyword library. Valid values: <br>- BLACK: a blacklist <br>- WHITE: a whitelist <br>- REVIEW: a review list |
| LibType | String | Yes | textKeyword | The library type within the moderation scenario. Valid values: <br>Text anti-spam (`ResourceType`: `TEXT`): <br>- textKeyword: matches individual terms in submitted text <br>- similarText: matches text patterns in submitted text <br>Ad violation detection (`ResourceType`: `IMAGE`): <br>- textKeyword: matches terms extracted from images <br>Audio anti-spam (`ResourceType`: `VOICE`): <br>- voiceText: matches terms converted from audio |
| MatchMode | String | No | fuzzy | The matching method. Valid values: <br>- fuzzy: fuzzy match <br>- precise: exact match |
| Enable | Boolean | No | true | Specifies whether to enable the keyword library immediately after creation. Valid values: <br>- true: enable the library. This is the default value. <br>- false: disable the library. |
Response parameters
For common response parameters returned by all AI Guardrails API operations, see Common response parameters.
| Parameter | Type | Example | Description |
|---|---|---|---|
| code | Integer | 200 | The HTTP status code. For a list of status codes, see Common error codes. |
| msg | String | OK | The message returned for the request. |
| requestId | String | 795D8871-4889-4C0F-A8B1-C7D2B990FF61 | The request ID. Use this ID to troubleshoot issues. |
| id | String | 123 | The ID of the created keyword library. Use this ID to manage the library in subsequent operations. |
Examples
Sample request
http(s)://green.cn-shanghai.aliyuncs.com/?Action=CreateKeywordLib&ServiceModule=open_api
&<Common request parameters>Request body:
{
"Name": "test1sdkdk",
"BizTypes": [],
"Category": "BLACK",
"ServiceModule": "open_api",
"ResourceType": "TEXT",
"LibType": "textKeyword"
}Sample success response
{
"RequestId": "795D8871-4889-4C0F-A8B1-C7D2B990FF61",
"code": 200,
"Id": "123"
}