Create an API Key
AI Guard uses OneTrust API keys for authentication and authorization. You need to create an API key with the Data Discovery scope to use with the SDK.
Steps
1. Navigate to API Key Management
- Log in to your OneTrust account
- Navigate to Settings > API Keys (or access via the OneTrust Admin Console)
Detailed InstructionsFor full step-by-step instructions on creating API keys, refer to the OneTrust API Key Management documentation.
2. Create a New API Key
- Click Create API Key
- Provide a descriptive name (e.g., "AI Guard SDK - Production")
- Under Scope, select Data Discovery
ImportantThe API key must have the Data Discovery scope enabled. Without this scope, the SDK will receive
401 Unauthorizederrors when making classification requests.
3. Copy and Store the API Key
- After creation, copy the generated API key immediately
- Store the key securely β it will be used as the
tokenparameter when initializing theAIGuardClient
Security Best PracticeNever hard-code API keys in your source code. Use environment variables or a secrets manager to store and retrieve the key at runtime.
Using the API Key
The API key is passed as the token parameter when initializing the AI Guard client:
from ai_guard import AIGuardClient
from ai_guard.api import AIPlatform
client = AIGuardClient(
"https://ai-guard.example.com:4443",
token="your-api-key-here", # Use an environment variable in production
agent_id="my-agent",
platform=AIPlatform.AMAZON_BEDROCK,
)Recommended pattern using environment variables:
import os
from ai_guard import AIGuardClient
from ai_guard.api import AIPlatform
client = AIGuardClient(
os.environ["AI_GUARD_URL"],
token=os.environ["AI_GUARD_TOKEN"],
agent_id="my-agent",
platform=AIPlatform.AMAZON_BEDROCK,
)What's Next?
- Deploy the Light Worker Node β Set up the AI Guard classification service
- Install the SDK β Download and install the Python SDK
Updated 3 days ago