Zscaler AI Guard Integration
The Zscaler AI Guard guardrail uses the Zscaler AI Guard API to scan prompts and LLM responses for security threats, including:
- Credentials and secrets - API keys, tokens, passwords, and cloud credentials
- PII (Personally Identifiable Information) - Names, emails, phone numbers, SSNs, and other personal data
- Toxicity - Violent, abusive, hateful, or harmful content
- Prompt injection - Adversarial prompts designed to manipulate AI behavior or bypass security controls
- Malicious URLs - Known malicious URLs and domains
- Policy violations - Custom content policy violations configured in the AI Guard console
The integration uses the zscaler-sdk-python SDK and implements fail-closed semantics: if the API call fails or returns an unexpected result, the integration blocks the content by default.
Data handling
The input rail sends the full user message to the Zscaler AI Guard API. The output rail sends the full bot response. Review Zscaler’s applicable privacy and data retention terms before enabling the integration in production.
Configuration
Configure the integration with the following environment variables:
AIGUARD_API_KEY: Required Zscaler AI Guard API key (Bearer token). To obtain this key, go to AI Guard Console > Private AI Apps > Applications > API Keys.AIGUARD_CLOUD: Optional cloud region. Options includeus1(default),us2,eu1, andeu2.
To use a specific policy instead of automatic resolution, set the following optional variable:
AIGUARD_POLICY_ID: Integer policy ID. When set, the integration callsexecute-policywith the specified ID instead ofresolve-and-execute-policy.
Setup
Colang v1
Colang v2
How It Works
- Input scanning: Before user prompts reach the LLM, the
zscaler aiguard moderation on inputflow sends the prompt to the AI Guard API withdirection="IN". - Output scanning: After the LLM generates a response, the
zscaler aiguard moderation on outputflow sends the response to the AI Guard API withdirection="OUT". - Policy selection: By default, the integration calls
resolve-and-execute-policy, which automatically selects the appropriate policy. IfAIGUARD_POLICY_IDis set, the integration callsexecute-policywith the specified policy ID instead. - Verdict handling: If the API returns an
actionofBLOCK, the flow aborts and the bot refuses to respond. If the API returnsALLOWorDETECT, the content passes through normally. - Rails exceptions: Setting
enable_rails_exceptions: trueat the top level of the config causes blocked requests to emit aZscalerAiguardInputRailExceptionorZscalerAiguardOutputRailException. The exception message contains the severity, policy name, blocking detectors, and transaction ID. - Fail-closed: If a scan fails because of a network error, timeout, or API error, the action returns a blocking
RailOutcomewithfailed=True. Its metadata includes the error type without the provider’s error details. This distinguishes a failed scan from a policy decision.IORailsreports an internal-error response; the Colang flows follow their configured blocking behavior.
Missing zscaler-sdk-python, a missing AIGUARD_API_KEY when initializing the SDK client, or a non-integer AIGUARD_POLICY_ID raises a setup error from the action. IORails converts these action errors to failed blocking outcomes, while the Colang runtime reports an internal error. IORails checks for the SDK dependency at startup, so a missing SDK prevents compilation. Through the Guardrails facade, the default behavior is to fall back to LLMRails; set require_iorails=True to reject that fallback. Refer to Rail Engine Support.
Detectors
The AI Guard policy engine evaluates all configured detectors and returns a single ALLOW / BLOCK / DETECT verdict. Available detectors include:
toxicity- Toxic or harmful languagepii- Personally identifiable informationpersonalData- Personal data patternspiiDeepscan- Deep PII scanningsecrets- Credentials, API keys, tokenspromptInjection- Prompt injection attemptsmaliciousUrl- Malicious URL detection
Configure detectors in the Zscaler AI Guard console, not in the NeMo Guardrails configuration.
Dependencies
Install the required SDK: