All Products
Search
Document Center

AI Guardrails:Installation

Last Updated:Mar 31, 2026

Install AI Guardrails SDK for PHP and configure credentials to start calling Content Moderation APIs.

Prerequisites

Before you begin, make sure you have:

Install the SDK

  1. Run the following command to install AI Guardrails SDK for PHP:

    composer require alibabacloud/green

    Alternatively, download the SDK source directly from GitHub.

  2. Add the following use declaration at the top of your PHP file to import the SDK namespace:

    use AlibabaCloud\Green\Green;

Configure environment variables

AI Guardrails SDK for PHP reads your AccessKey credentials from environment variables. Set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET before running SDK code — this keeps credentials out of your source files.

macOS and Linux

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

To persist these variables across sessions, add the two export lines to your ~/.bashrc or ~/.zshrc file.

Windows (Command Prompt)

setx ALIBABA_CLOUD_ACCESS_KEY_ID <your-access-key-id>
setx ALIBABA_CLOUD_ACCESS_KEY_SECRET <your-access-key-secret>

Replace <your-access-key-id> and <your-access-key-secret> with your actual AccessKey ID and AccessKey secret. For instructions on creating an AccessKey pair, see Configure credentials.

Next steps