To use Content Moderation SDK for Go 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: China (Shanghai)
- cn-beijing: China (Beijing)
- cn-shenzhen: China (Shenzhen)
- ap-southeast-1: Singapore (Singapore)
Use the following code to create a client instance to moderate images, audio, videos,
and text:
// Use the AccessKey ID and AccessKey secret of your Alibaba Cloud account.
client, err := green.NewClientWithAccessKey("cn-shanghai", "Your AccessKey ID", "Your AccessKey secret")
if err != nil {
// handle exceptions
panic(err)
}
Note If you create a client instance in a region other than cn-shanghai, replace
cn-shanghai
in the preceding code with the ID of the region, for example, cn-beijing
.