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 RepositoryThe 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:
| Package | Version | Purpose |
|---|---|---|
cryptography | β₯ 43.0.0 | TLS certificate pinning support |
python-dotenv | β₯ 1.0.0 | Environment variable management |
requests | β₯ 2.25.0 | HTTP 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-sdkWhat's Next?
- Initialize the Client β Configure the SDK and connect to your AI Guard service
- Classify Text β Start classifying text for sensitive data
- Redact Sensitive Data β Apply redaction policies to classification results
Updated about 4 hours ago