Before you use Content Moderation SDK for .NET to initiate an API request, create a client instance and modify the client configurations as needed.
Background information
When you create a client instance, you must specify the region as well as the AccessKey ID and AccessKey secret of your Alibaba Cloud account.
For more information about the supported regions, see Endpoints.
For more information about how to obtain the AccessKey ID and AccessKey secret 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
Use the following code to create a client instance to moderate images, audio, videos, and text:
/**
* Common ways to obtain environment variables:
* Obtain the AccessKey ID of your RAM user: Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID");
* Obtain the AccessKey secret of your RAM user: Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
*/
DefaultProfile profile = DefaultProfile.GetProfile(
"cn-shanghai",
"We recommend that you obtain the AccessKey ID of your RAM user from environment variables",
"We recommend that you obtain the AccessKey secret of your RAM user from environment variables");
DefaultAcsClient client = new DefaultAcsClient(profile);
If you create a client instance in a region other than the China (Shanghai) region, for example, cn-beijing
, replace cn-shanghai
in the preceding code with the ID of the region.