OneTrust AI Guard SDK Guide
Overview
AI Guard by OneTrust is one of the industry’s leading comprehensive classification tools for protecting critical AI systems. AI Guard acts as a sophisticated inspection layer, sitting between your users and AI tools to ensure every interaction is safe, secure, and compliant.
AI Guard aims to help businesses develop AI apps with confidence, especially during the build phases. Businesses can sometimes struggle to identify PII risk in their AI payload, and AI guard helps identify such risks early in the development phase by providing sophisticated PII identification and data classification. By using AI Guard, businesses can create AI agents or apps that can be tested for PII generation and quantify the PII risk from such AI applications before taking them to production.
Performance Note: AI Guard Classification service (lightweight worker node) can classify over 300 requests in a second, with an average wait of 75 milliseconds per request with 1 vCPU and a 200-character payload.
AI Guard is SDK-based, making it suitable for almost all types of environments with a Python runtime environment. Businesses can import OneTrust AI Guard as an SDK and leverage its functionalities. AI Guard addresses two primary use cases:
- AI application inventory
-
Allows developers to import OneTrust AI Guard as an SDK within their apps and declare the AI application metadata, thereby registering the application to the OneTrust AI Governance solution for AI Governance. This allows businesses to centralize all the business apps that are being developed and ensure AI Governance actions required can be extended to these apps.
- AI Classification service to Protect Sensitive Data
-
Automatically detect and mask PII, secrets, proprietary code, and much more with support for 300+ classification possibilities out-of-the-box and the ability to define custom profiles.
AI Guard runs within the customer environment through the OneTrust lightweight worker node or as a standalone on-premises service. The lightweight worker node provides the local runtime for classification and secure communication with OneTrust Cloud, while the standalone deployment supports customer-managed environments such as Kubernetes, ECS, Nomad, Docker Swarm, and Docker.
AI Guard supports OpenTelemetry metrics and traces for your AI applications' observability.
Prerequisites
-
OneTrust AI Governance subscription
-
OneTrust API key with the DATA DISCOVERY and AI_GOVERNANCE scope
-
One of the following deployment options:
-
Deployed OneTrust lightweight worker node
-
Standalone AI Guard on-premises deployment
-
-
Python 3.13 or later when using the Python SDK
-
TLS certificate and private key in PEM format for secure deployments
-
Required network access:
-
Port 4443 for AI Guard classification
-
Port 4317 when using the OpenTelemetry collector
-
-
For standalone deployment, access to the
docker.onetrust.dev/ai-guard-onpremimage is required. Customers may pull the image directly from the private OneTrust Docker registry or mirror the approved image into their own private registry before deployment. The image supports Linuxamd64andarm64platforms.
Solution Summary
-
Create API keys within the OneTrust AI Governance solution.
-
Deploy AI Guard using either the OneTrust lightweight worker node or the standalone AI Guard on-premises Docker image. The standalone image can run on Kubernetes, ECS, Nomad, Docker Swarm, or Docker.
-
The standalone deployment can run classification, OpenTelemetry (OTLP) collection, or both. OTLP collection can receive telemetry from the AI Guard SDK or from any OTLP-compliant producer
-
OneTrust AI Guard (SDK) is consumed within a business AI app, such as an AI agent.
-
OneTrust AI Guard (SDK) is initialized with environmental parameters and with an API Key.
OneTrust AI Governance Cloud acts as a control plane to define the classification behavior and does not collect prompts or responses. A summary of classification results (metrics) is sent from the lightweight worker node to the OneTrust AI Governance solution in regular intervals to create a PII classification metric history.
Configuration
1. Create API Key
-
Refer to Managing OAuth 2.0 API Keys to create an API key to authorize the SDK.
-
Ensure the API key’s scope is DATA DISCOVERY and AI_GOVERNANCE.
2. For worker node deployment:
-
Deploy a lightweight worker node. Refer to Lightweight Worker Node Deployment for AI Automations to create and deploy the lightweight worker node.
The lightweight worker node serves as the classification service and a secure communication link between the AI Guard SDK and OneTrust Cloud. AI Guard is one of the many supported feature sets of the lightweight worker node.
3. For standalone deployment:
-
Docker image - pull the AI Guard on-premises Docker image and deploy it to your supported container platform.
-
Registry credentials - configure the read-only credentials required to pull the image from the OneTrust container registry. If your organization uses a mirrored image in its own registry, use your registry's authentication method instead.
-
TLS certificates - provide TLS certificates to secure connections to AI Guard. You can use certificates issued by your organization's certificate authority or by a publicly trusted one.
-
Authentication tokens - create and configure OAuth client credentials or an API key to authenticate AI Guard with OneTrust.
4. Import the SDK
-
Go to the OneTrust Developer Portal and search for AI Guard under SDKs. You can also visit our GitHub and search for AI guard.
-
Copy or download the SDK.
-
Follow the instructions here to leverage the SDK.
5. Classification Verification
Using the steps outlined in the SDK, developers should be able to classify information being received from users or from AI systems and take actions such as redact or block information. Examples below are for illustrative purposes only.
-
Example of PII Redaction in action
-
Example of PII Block in action
6. Changing Classification Profile
Classification actions are carried out inside the lightweight worker node (referred to as the AI Guard Classification service) and use classification profiles. OneTrust supports more than 300+ classification profiles.
The AI Guard Classification Service uses the default Classification Profile as defined within the OneTrust Platform. While the default classification profile can be changed for a specific customer tenant by the OneTrust admin, this is not recommended. OneTrust recommends instead to leverage specific classification profiles. This way, you can use AI Guard SDK to reference specific classification profiles by name.
Custom classification profiles are not currently supported for AI Guard operations.
Managing AI Guard Agent and Metrics
AI Agents being developed or running in production can leverage the AI Guard SDK, allowing developers to register the agent to the OneTrust platform and ensuring visibility into the Agent lifecycle. To verify Agent registration via AI Guard SDK, navigate to AI Agents and select the source type as AI Guard.
To verify that the AI Guard SDK and the Lightweight Worker Node are producing classification results, navigate to the specific Agent created and in the details section, navigate to Attribute Group Sensitive Data Classification. The AI Guard - Prompt PII Count and AI Guard - Response PII Count metrics are available.
Data displayed reflects Last One Hour of data.
Monitoring and Enforcing Thresholds
To monitor and enforce thresholds for metrics reported, it is highly encouraged to set up custom policies and track individual metrics or groups of metrics against an organizationally defined threshold. A breach in these thresholds results in policy violations and allows to surface deviations in a large agent inventory.
For more information on creating custom policies, see AI Policies Feature Guide.