Install the AI Guardrails SDK for .NET to start calling Content Moderation API operations from your .NET application.
Prerequisites
Before you begin, ensure that you have:
An Alibaba Cloud account with Content Moderation activated
An AccessKey pair — see Configure credentials
.NET Framework 4.5 or later
.NET Standard 2.0 or later
C# 4.0 or later
Install the SDK
Download AI Guardrails SDK for .NET, then install the packages using one of the following methods.
Install using the .NET Core CLI
Run the following commands:
dotnet add package aliyun-net-sdk-core
dotnet add package aliyun-net-sdk-greenTo pin a specific version, append--version <version-number>to each command. For example:dotnet add package aliyun-net-sdk-core --version 1.0.0. Without a version flag, the latest version is installed.
Install using dotnet build
Add the following entries to your
.csprojfile:<PackageReference Include="aliyun-net-sdk-core" Version="1.5.10" /> <PackageReference Include="aliyun-net-sdk-green" Version="3.6.5" />Run the build command to install the packages:
dotnet build
Verify the installation
Run the following command to confirm both packages are installed:
dotnet list packageThe output should include aliyun-net-sdk-core and aliyun-net-sdk-green.
Configure environment variables
The SDK reads your AccessKey pair from environment variables, which keeps credentials out of your source code. Set the following environment variables before running any SDK code.
Windows:
setx ALIBABA_CLOUD_ACCESS_KEY_ID <your-access-key-id>
setx ALIBABA_CLOUD_ACCESS_KEY_SECRET <your-access-key-secret>Linux/macOS:
export ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>Replace <your-access-key-id> and <your-access-key-secret> with the values from your AccessKey pair.
Restart your terminal or IDE after setting environment variables for the changes to take effect.
What's next
After installation, use the SDK to call Content Moderation API operations. For code examples, see the AI Guardrails SDK for .NET README.