Installation

更新时间:
复制 MD 格式

Install the AI Guardrails SDK for Go and configure your credentials to start calling Content Moderation APIs.

Prerequisites

Go 1.10.0 or later is required. Verify your current version:

go version

Install the SDK

  1. Download the AI Guardrails SDK for Go.

  2. Run the following command to install AI Guardrails SDK for Go:

    go get -u github.com/aliyun/alibaba-cloud-sdk-go/sdk
  3. Add the SDK import path to your source file:

    import "github.com/aliyun/alibaba-cloud-sdk-go/services/green"

Configure environment variables

The SDK reads your AccessKey pair from two environment variables: ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. Set these before running any SDK code.

Linux/macOS:

export ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>

Windows (Command Prompt):

set ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
set ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>

For other credential types (RAM roles, STS tokens), see Configure credentials.