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 — Detect and redact credit-card-like data in Chat input.
- Block secrets — Block prompts that contain private-key-like content.
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#
| 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#
| 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#
- Confirm that the configured Redact action is applied to the matching input.
- Open the policy detail page and review Usage Statistics.
- Confirm that Requests evaluated and guardrail invocation metrics increase after test traffic.
How the request is evaluated#
For a matching request:
- The policy evaluates the request conditions.
- The linked guardrail runs at the configured Input stage.
- Matching PII is detected and the Redact action is applied.
- 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#
| 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#
| 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#
- Send a matching Chat or API request containing private-key-like content.
- Confirm that the request is blocked when the Secrets guardrail detects
PRIVATE_KEY. - Open the guardrail detail page and confirm that invocation metrics increase.
- 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.