Install the SDK

The AI Guard SDK is a Python package that you import into your AI application. It provides classification, redaction, and streaming capabilities.

Requirements

  • Python 3.13 or higher
  • pip package manager

Installation Methods

Install from PyPI (Recommended)

pip install "ai-guard-sdk @ git+https://github.com/onetrust-oss/ai-guard-sdk.git"

Install from Source

If you need to install from the source repository:

git clone <repo-url>
cd ai-guard
python -m venv .venv
source .venv/bin/activate
pip install .
πŸ“˜

Source Repository

The AI Guard SDK source is also available on GitHub.

Verify Installation

After installation, verify the SDK is available:

python -c "from ai_guard import AIGuardClient; print('AI Guard SDK installed successfully')"

Quick Start

Here is a minimal example to verify end-to-end connectivity with your AI Guard service:

from ai_guard import AIGuardClient
from ai_guard.api import (
    AIPlatform,
    ClassificationRequest,
    ClassifierDescriptionDefault,
)

# Initialize the client
client = AIGuardClient(
    "https://ai-guard.example.com:4443",
    token="your-api-key",
    agent_id="my-agent",
    platform=AIPlatform.AMAZON_BEDROCK,
)

# Classify sample text
request = ClassificationRequest(
    context={"actor": "user"},
    classifier_description=ClassifierDescriptionDefault(),
    text="Call me at 321-507-0525",
)

response = client.classify(request)

for match in response.matches:
    print(f"{match.classifier}: '{match.text}' (confidence: {match.confidence})")
# Expected output:
# US_PHONE_NUMBER: '321-507-0525' (confidence: 100)

If you see classification results, your installation and connectivity are working correctly.

Dependencies

The SDK installs the following dependencies automatically:

PackageVersionPurpose
cryptographyβ‰₯ 43.0.0TLS certificate pinning support
python-dotenvβ‰₯ 1.0.0Environment variable management
requestsβ‰₯ 2.25.0HTTP client for service communication

Virtual Environment (Recommended)

We recommend using a Python virtual environment to isolate AI Guard SDK dependencies:

# Create a virtual environment
python -m venv .venv

# Activate it
source .venv/bin/activate    # macOS/Linux
.venv\Scripts\activate       # Windows

# Install the SDK
pip install ai-guard-sdk

What's Next?