To use Content Moderation SDK for Python to initiate an API call, initialize a client instance and modify the client configurations as needed.

Background information

When you create a client instance, you must specify the region and the AccessKey ID and AccessKey secret of your Alibaba Cloud account.
  • For more information about the supported regions, see Endpoints.
  • For more information about the AccessKey pair of an Alibaba Cloud account, see Obtain an AccessKey pair.

Create a client instance to moderate images, audio, videos, and text

The following regions are supported:
  • cn-shanghai
  • cn-beijing
  • ap-southeast-1
Use the following code to create a client instance to moderate images, audio, videos, and text:
from aliyunsdkcore import client
# Use the AccessKey ID and AccessKey secret of your Alibaba Cloud account. You can add the AccessKey ID and AccessKey secret to the profile or directly enter them in plaintext in the code.
clt = client.AcsClient("Your AccessKey ID", "Your AccessKey secret","cn-shanghai")

Create a client instance to manage custom image libraries, term libraries, and text pattern libraries

The supported region is cn-shanghai. The server can automatically synchronize data if you initiate a request in a region other than cn-shanghai.

Use the following code to create a client instance to manage custom image libraries, term libraries, and text pattern libraries:
from aliyunsdkcore import client
# Use the AccessKey ID and AccessKey secret of your Alibaba Cloud account. You can add the AccessKey ID and AccessKey secret to the profile or directly enter them in plaintext in the code.
clt = client.AcsClient("Your AccessKey ID", "Your AccessKey secret","cn-shanghai")