This topic shows you how to call the CreateKeywordLib operation to create a custom text library. You can use text libraries for text anti-spam. The effect of managing custom text libraries by calling API operations is the same as that of managing custom text libraries in the Alibaba Cloud Content Moderation console.

Description

Operation: CreateKeywordLib

Create a text library. You can apply text libraries to the following moderation scenarios:
  • Text anti-spam: detects text violations.
  • Ad violation detection: detects ads or illegal text in images.
  • Audio anti-spam: detects audio violations.

You can also create a text library in the Alibaba Cloud Content Moderation console. For more information, see Manage custom text libraries.

Request parameters

For more information about the common request parameters that must be included in all Content Moderation API requests, see Common parameters.

The following table describes the parameters in the request body.
Parameter Type Required Description
ServiceModule String Yes

The name of the service module. Set the value to open_api.

Name String Yes The name of the text library.
ResourceType String Yes The moderation scenario to which the text library applies. Valid values:
  • TEXT: text anti-spam.
  • IMAGE: ad violation detection.
  • VOICE: audio anti-spam.
BizTypes List No The business type of the custom text library that you set on the Moderation Policy tab by choosing Settings > Moderation API.
Category String Yes The category of the text library. Valid values:
  • BLACK: a blacklist.
  • WHITE: a whitelist.
  • REVIEW: a review list.
LibType String Yes The type of the text library in each moderation scenario. Valid values:
  • Text anti-spam
    • textKeyword: a text library against which terms in text are matched.
    • similarText: a text library against which text patterns are matched.
  • Ad violation detection

    textKeyword: a text library against which terms extracted from images are matched.

  • Audio anti-spam

    voiceText: a text library against which terms converted from audio are matched.

MatchMode String No The matching method. Valid values:
  • fuzzy: fuzzy matching.
  • precise: exact matching.
Enable Boolean No Specifies whether to enable the text library. A value of true indicates that the text library is enabled, and a value of false indicates that the text library is disabled.

Response parameters

For more information about common response parameters that this operation returns, see Common response parameters.
Parameter Type Required Description
code Integer Yes The error code. Most error codes are consistent with HTTP status codes, and some error codes are extended.
  • 2xx: indicates a success.
  • 4xx: indicates an invalid request.
  • 5xx: indicates a backend error.
For more information, see Common HTTP status codes.
msg String No The description of the call error.
requestId String Yes The unique ID of the request, which can be used to locate issues.
id String Yes The unique ID of the text library, which can be used to perform subsequent operations on the text library.

Examples

Sample requests
{
  "Name": "test1sdkdk",
  "BizTypes": [],
  "Category": "BLACK",
  "ServiceModule": "open_api",
  "ResourceType": "TEXT",
  "LibType": "textKeyword"
}
Sample success responses
{
  "RequestId": "795D8871-4889-4C0F-A8B1-C7D2B990FF61",
  "code": 200,
  "Id":123
}