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

Precautions

When creating 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 Request structure.
  • For more information about how to obtain the AccessKey ID and AccessKey secret of your Alibaba Cloud account, see Create an AccessKey.

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

The following regions are supported:
  • cn-shanghai: China (Shanghai)
  • cn-beijing: China (Beijing)
  • ap-southeast-1: Singapore
  • us-west-1: US (Silicon Valley)
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")