Skip to navigation

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 include us1 (default), us2, eu1, and eu2.

To use a specific policy instead of automatic resolution, set the following optional variable:

  • AIGUARD_POLICY_ID: Integer policy ID. When set, the integration calls execute-policy with the specified ID instead of resolve-and-execute-policy.

Setup

Colang v1

# config.yml
# Optional: show detailed block messages (severity, policy name, detectors)
enable_rails_exceptions: true
rails:
input:
flows:
- zscaler aiguard moderation on input
output:
flows:
- zscaler aiguard moderation on output

Colang v2

# config.yml
colang_version: "2.x"
# rails.co
import guardrails
import nemoguardrails.library.zscaler_aiguard
flow input rails $input_text
zscaler aiguard moderation on input
flow output rails $output_text
zscaler aiguard moderation on output

How It Works

  1. Input scanning: Before user prompts reach the LLM, the zscaler aiguard moderation on input flow sends the prompt to the AI Guard API with direction="IN".
  2. Output scanning: After the LLM generates a response, the zscaler aiguard moderation on output flow sends the response to the AI Guard API with direction="OUT".
  3. Policy selection: By default, the integration calls resolve-and-execute-policy, which automatically selects the appropriate policy. If AIGUARD_POLICY_ID is set, the integration calls execute-policy with the specified policy ID instead.
  4. Verdict handling: If the API returns an action of BLOCK, the flow aborts and the bot refuses to respond. If the API returns ALLOW or DETECT, the content passes through normally.
  5. Rails exceptions: Setting enable_rails_exceptions: true at the top level of the config causes blocked requests to emit a ZscalerAiguardInputRailException or ZscalerAiguardOutputRailException. The exception message contains the severity, policy name, blocking detectors, and transaction ID.
  6. Fail-closed: If a scan fails because of a network error, timeout, or API error, the action returns a blocking RailOutcome with failed=True. Its metadata includes the error type without the provider’s error details. This distinguishes a failed scan from a policy decision. IORails reports 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 language
  • pii - Personally identifiable information
  • personalData - Personal data patterns
  • piiDeepscan - Deep PII scanning
  • secrets - Credentials, API keys, tokens
  • promptInjection - Prompt injection attempts
  • maliciousUrl - Malicious URL detection

Configure detectors in the Zscaler AI Guard console, not in the NeMo Guardrails configuration.

Dependencies

Install the required SDK:

pip install zscaler-sdk-python