AI gateway guardrails are checks that run at the gateway between your application and the model provider, inspecting what goes in and what comes back. Deterministic guardrails, such as pattern checks and length limits, give the same answer every time and are simple to test. Model-based checks catch more but vary, so each needs its own test set. PII masking by pattern catches formats you can describe, such as card numbers, and misses names and addresses in free text. This guide explains where guardrails sit, how to split the work between deterministic and model-based checks and what to put in a test set before go-live. Product facts below come from the WSO2 documentation. The gateway is now named Choreo AI Gateway (formerly WSO2 AI Gateway), after Choreo Labs, formerly WSO2, renamed on November 17, 2026.
Where guardrails sit
A guardrail sits on the traffic path, so every call passes through it whether the application or the developer remembers or not. That is the difference between a guardrail and a prompt instruction: the instruction is a request to the model, while the guardrail is enforced outside it. The WSO2 guardrail overview describes guardrails between your application and the model provider that check both inputs and outputs.
| Position | What it can do | Example |
|---|---|---|
| On the request | Block, mask or reshape what the model sees | Mask a card number before it leaves your network |
| On the response | Block or flag what the application receives | Reject a reply that breaks a required format |
| Per API or proxy | Apply rules to one application | Stricter rules on a customer-facing assistant |
| Per organisation | Apply a floor everywhere | Always mask account numbers |
The overview does not describe the order the checks run in or what the caller sees on a block, so confirm both in a lab. For the wider setup, see WSO2 AI Gateway setup and registration and the gateway setup page.
PII masking
Pattern masking replaces text that matches a rule you define. It is strong where the data has a fixed shape and weak where it does not.
| Data | Pattern masking | Add |
|---|---|---|
| Card and account numbers | Good, with a check digit test where available | Tests for spaced and split forms |
| Government ID numbers | Good, if the format is fixed | Country-specific patterns |
| Email addresses and phone numbers | Good | Variants with spaces or words |
| Names | Poor | Meaning-based or external check |
| Street addresses | Poor | Meaning-based or external check |
| Medical or case details in free text | Poor | Meaning-based check and human review |
Mask before the data leaves your network and before it reaches logs. The record should show that a mask applied, not the value. Our PII masking scenario walks through a health system case with synthetic data.
Deterministic vs model checks
| Deterministic | Model-based | |
|---|---|---|
| Examples in the 4.7.0 list | Content length, word and sentence count, regex, JSON schema, URL, PII masking with regex | Semantic prompt, semantic tool filtering, Azure Content Safety, AWS Bedrock Guardrail |
| Same input, same result | Yes | Not always |
| Test effort | Low | Higher, needs a larger set and repeat runs |
| Catches new phrasing | No | Often |
| Failure shape | Misses what the rule did not describe | Misses or blocks by judgment |
| Where to place | First, as the hard floor | After, for what rules cannot describe |
Put hard rules first and keep a deterministic check as the last word on anything that must never pass. Why a hard rule belongs after a classifier is argued in our piece on prompt injection controls.
Test set
Build the set before you configure the guardrails, and keep it in version control. Use synthetic data only.
| Group | Cases | Expected outcome |
|---|---|---|
| Normal traffic | 10 to 20 ordinary prompts | Pass and logged |
| Card, account and ID patterns | Plain, spaced, split across lines, inside a sentence | Masked |
| Names and addresses in free text | Several forms | Flagged or masked by the meaning-based check |
| Over-length prompt | One far over the limit | Rejected |
| Refused topic | Prompts on topics you deny | Denied |
| Structured output | Response that must match a JSON shape | Fails when the shape is wrong |
| Tricks | Obfuscated numbers, instructions to ignore rules | Blocked or flagged, and every miss recorded |
| Repeat runs | Same prompt several times on model-based checks | Consistent outcome, or recorded variance |
Record the result for every case, the release and guardrail version and who ran it. Re-run the set after every change to a rule, a provider or a release. The set is also your regression test when you upgrade, as the setup guide suggests.
Check the cases that fail, not the ones that pass. A mask that works on 19 of 20 card formats leaves a gap an attacker or a typo will find.
Common mistakes
- Testing with real customer data instead of synthetic data.
- Treating a passing demo as a passing test set.
- Putting every check on a model-based service and losing repeatability.
- Logging the original value next to the mask event.
- Skipping the test after a provider, rule or release change.
A first engagement
Duczer East offers an AI gateway fit check: we review where the gateway runs, the release it needs and the guardrails to attach, then test them with a prompt set and hand back a short written plan. See WSO2 AI Gateway setup.



