Creates 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.

Operation description

Operation: CreateKeywordLib

You can call this operation to create a text library. For more information about how to construct an HTTP request, see Request structure. You can also select an existing HTTP request. For more information, see SDK overview.

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.

Billing method: This operation is free of charge.

QPS limit

You can send up to 10 requests per second to call this operation by using your Alibaba Cloud account. If you send an excessive number of requests, throttling is implemented, and your business may be affected.

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 Example Description
ServiceModule String Yes open_api

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

Name String Yes test1sdkdk The name of the text library.
ResourceType String Yes TEXT The moderation scenario to which the text library applies. Valid values:
  • TEXT: text anti-spam
  • IMAGE: ad violation detection
  • VOICE: audio anti-spam
BizTypes StringArray No ["bizTypeA","bizTypeB"] The business type of the custom text library that you set on the Moderation Policy tab by choosing Settings > Moderation API.
Category String Yes BLACK The category of the text library. Valid values:
  • BLACK: a blacklist
  • WHITE: a whitelist
  • REVIEW: a review list
LibType String Yes textKeyword 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 fuzzy The matching method. Valid values:
  • fuzzy: fuzzy matching
  • precise: exact matching
Enable Boolean No true Specifies whether to enable the text library. Valid values:
  • true: enables the text library.
  • false: disables the text library.

Response parameters

For more information about common response parameters that this operation returns, see Common response parameters.
Parameter Type Example Description
code Integer 200 The returned HTTP status code.

For more information, see Common HTTP status codes.

msg String OK The message that is returned for the request.
requestId String 795D8871-4889-4C0F-A8B1-C7D2B990FF61 The unique ID of the request, which can be used to locate issues.
id String 123 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
}