Guardrails
Per-user keyword policies that block or flag chat requests before they reach a provider.
Guardrails are per-user policies that scan chat request bodies for keywords you specify. Each policy behaves one of two ways depending on its action — block rejects a matching request before the provider is called, while flag lets the request pass through and only records an audit event.
Guardrails are distinct from PII masking. Masking redacts sensitive content and still sends the request to the provider, whereas guardrails block or flag the matching request itself.
Managing policies#
Policies are managed with your logged-in session (JWT). List with GET /v1/guardrails, update with PATCH /v1/guardrails/{id}, and delete with DELETE /v1/guardrails/{id}. Creating one returns 201 on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Policy name. 1 to 100 characters. |
| blocked_terms | string[] | Optional | Array of keywords to block/flag. Default []. Case-insensitive substring matching; blank entries are stripped. |
| action | string | Optional | block or flag. Default block. |
curl https://apirouter.pleum.ai/v1/guardrails \
-H "Authorization: Bearer <JWT>" \
-H "Content-Type: application/json" \
-d '{
"name": "no-secrets",
"blocked_terms": ["api_key", "AWS_SECRET", "password"],
"action": "block"
}'Enforcement#
Guardrails are applied at call time on /v1/chat/completions, /v1/messages, and /v1/responses, before the provider is called. Matching scans text parts only; image parts are ignored.
When a block policy matches, the request is rejected with HTTP 403, and the body carries error, message, and the matched policy's guardrail name. The provider is never called, so no credits are charged.
{
"error": "guardrail_blocked",
"message": "Request blocked by a guardrail policy.",
"guardrail": "no-secrets"
}When a flag policy matches, the request passes through and only an audit event is recorded. No request content is stored — only the policy name and the matched term.