Skip to content

End-to-end Examples#

This page provides end-to-end examples for configuring policies and guardrails and verifying their behavior in Chat traffic.

Examples:

Redact PII in Chat prompts#

This example validates PII protection for Chat Completion traffic and shows where to check evidence after sending test prompts. For field-level procedures, see Guardrails — Add a guardrail and Policies — Add a policy. The example assumes that the organization and provider are already configured.

Create the guardrail#

Table 1: Example guardrail configuration
Field Example value
Name test-PII
Description This guardrail tests PII detection and redaction on input
Type PII detection and redaction
Stage Input
Threshold 0.7
Action Redact
PII fields CREDIT_CARD
Custom regexp patterns Optional (leave empty for this test)

Save the guardrail.

Create the policy#

Table 2: Example policy configuration
Field Example value
Name chat-pii-check
Description Validate PII guardrail
Enabled On
Conditions request_type == "chat_completion"
Stage Input
Sampling rate 100% during testing
Timeout 1500 ms
Request type Chat Completion
Pass on timeout Off (for strict validation)
Linked guardrails test-PII

Important: keep policy Stage aligned with the linked guardrail Stage for this test. The guardrail is Input, so set the policy Stage to Input.

Save the policy.

Send test prompts#

Use an enabled provider and send prompts that include test credit-card-like values.

Example test prompt:

My test card is 4111 1111 1111 1111, summarize this message.

Run at least 3 to 5 requests so counters are easier to verify.

Verify the result#

  1. Confirm that the configured Redact action is applied to the matching input.
  2. Open the policy detail page and review Usage Statistics.
  3. Confirm that Requests evaluated and guardrail invocation metrics increase after test traffic.

How the request is evaluated#

For a matching request:

  1. The policy evaluates the request conditions.
  2. The linked guardrail runs at the configured Input stage.
  3. Matching PII is detected and the Redact action is applied.
  4. Policy usage statistics record the evaluation.

Troubleshooting#

  • Confirm policy is Enabled.
  • Confirm guardrail is linked to that policy.
  • Confirm request type and conditions match your real traffic.
  • Confirm Sampling rate is 100% during testing.
  • Confirm policy/guardrail Stage alignment.

Block secrets#

This example blocks prompts that contain private-key-like secrets before they reach a provider. The Secrets guardrail shows Action and Secret types after you select Type = Secrets. For field-level procedures, see Add a guardrail and Add a policy.

The example assumes that the organization and provider are already configured.

Create the guardrail#

Table 3: Example guardrail — secrets
Field Example value
Name secrets-input
Description Block private key leaks in user prompts
Stage Input
Type Secrets
Action Block
Secret types PRIVATE_KEY

Save the guardrail. Keep guardrail Stage aligned with the linked policy Stage.

Create the policy#

Table 4: Example policy settings for the secrets guardrail
Policy field Example value
Name chat-secrets-check
Description Block private keys in chat prompts
Enabled On
Conditions Rule Builder: Request type = chat_completion
Stage Input
Sampling rate 100% during testing
Timeout 1500 ms
Request type Chat Completion
Pass on timeout Off for strict blocking tests
Linked guardrails secrets-input

Save the policy.

Send a test request#

Send a matching Chat or API request that contains private-key-like content.

Verify the result#

  1. Send a matching Chat or API request containing private-key-like content.
  2. Confirm that the request is blocked when the Secrets guardrail detects PRIVATE_KEY.
  3. Open the guardrail detail page and confirm that invocation metrics increase.
  4. Open the policy Usage Statistics tab and confirm that the request was evaluated.

See also#

  • Policies — Configure policy conditions and evaluation scope.
  • Guardrails — Configure guardrail types, stages, thresholds, and actions.
  • Policy and Guardrail Limits — Review runtime considerations and troubleshooting guidance.