Guard
Reliant Guard is a bidirectional AI safety layer. It filters user messages before they reach the AI provider (Input Guard), and validates AI responses before they reach the user (Output Guard). One API call replaces fragile prompt engineering with runtime enforcement in both directions.
POST /guard/chat
The recommended endpoint. Guard calls your configured AI provider internally, validates the response through all active layers, and returns the final safe response — in a single call.
Body
| Field | Type | Required | Description |
|---|---|---|---|
| user_message | string | yes | The message sent by the end user |
| guard_id | string | yes | Guard config ID created in Dashboard → Guard |
| user_id | string | yes | Your User ID (Dashboard → Settings) |
Response
| Field | Type | Description |
|---|---|---|
| allowed | boolean | Whether the message passed all guard layers |
| response | string | The final response to deliver to the user. Safe response if blocked. |
| blocked_by | string | null | See values below. null if allowed. |
| block_reason | string | null | Human-readable explanation of why it was blocked |
| latency_ms | number | Total latency. Near-zero when input is blocked before the AI call. |
blocked_by values
| Value | Layer | Description |
|---|---|---|
input_keyword | Input Guard | User message matched a blocked keyword |
input_pattern | Input Guard | User message matched a blocked regex pattern |
input_pii | Input Guard | User message contains PII (CPF, credit card, phone) |
input_toxic | Input Guard | LLM detected hate speech, threats, or harassment |
input_injection | Input Guard | LLM detected a prompt injection or jailbreak attempt |
topic | Output Guard | AI response discussed a blocked or off-scope topic |
data | Output Guard | AI response contained a blocked pattern or keyword |
tone | Output Guard | AI response violated tone rules |
user_limit | Limits | End-user exceeded their execution quota |
project_limit | Limits | Project exceeded its execution quota |
token_limit | Limits | End-user exceeded their token quota |
POST /guard
Validate-only endpoint. Pass your own AI response for Guard to inspect. Use this when you already have the AI response and just need the validation layer.
Guard layers
Guard runs two groups of layers in sequence: Input Guard (before the AI call) and Output Guard (after the AI call). A block at any layer short-circuits the rest.
Input Guard layers
These run on the user message before it is sent to the AI provider. A blocked input returns immediately — zero tokens consumed.
⬤ Input Keywords & Patterns
Fast string and regex matching on the user message. No LLM call. Configure input_blocked_keywords (exact match) and input_blocked_patterns (regex) in the Guard dashboard.
⬤ PII Blocker
Detects personal data in user messages before it reaches the AI. Built-in patterns cover CPF, credit card numbers, and Brazilian phone numbers. Enable with block_pii_input: true.
⬤ Toxic Content & Prompt Injection (LLM)
Uses an LLM-as-judge (Haiku) to detect hate speech, threats, harassment, or jailbreak attempts in the user message. Enable independently with block_toxic_input and block_prompt_injection.
Output Guard layers
These run on the AI response after the provider call, before delivery to the user.
◎ Topic Guard
Defines what the AI is allowed or not allowed to discuss. Uses LLM-as-judge to evaluate whether the response stays within the configured scope. Configure allowed_topics and blocked_topics in the Guard dashboard.
◫ Data Shield
Blocks responses containing sensitive data patterns or keywords. Runs instantly using regex and string matching — no LLM cost. Configure blocked_keywords and blocked_patterns (regex) in the Guard dashboard.
◈ Tone & Compliance
Enforces brand voice and content policies. Uses LLM-as-judge to evaluate whether the response matches your configured tone_rules. Blocked phrases run instantly without LLM cost.
Integration example
Complete WhatsApp bot integration using /guard/chat:
response field is always safe to deliver to the user — whether the request was allowed or blocked. You don't need to check allowed unless you want to log or handle blocked requests differently.⬡ Reliant Limits
Limits control how many executions a project or an end-user can make within a period. When a limit is reached, the configured safe_response is returned automatically — no error, no broken app.
| Field | Type | Description |
|---|---|---|
| max_executions_per_period | number | Max executions for the whole project per period |
| period_type | string | hourly, daily, or monthly |
| limit_response | string | Response returned when project limit is reached |
| max_executions_per_user | number | Max executions per end-user per period |
| user_period_type | string | hourly, daily, or monthly |
| user_limit_response | string | Response returned when user limit is reached |
To enable per-user tracking, pass end_user_id in the /guard/chat request body — typically a phone number, user ID, or session token.
When a limit is hit, the response looks like this:
GET /guard/usage/:guard_id
Returns current period usage for a Guard — project total and top end-users by volume.
Guard config endpoints
GET /guard/configs
List all Guard configs for the authenticated project.
POST /guard/configs
Create a Guard config programmatically. Fields are split into Input Guard (run before the AI call) and Output Guard (run after).
Input Guard fields
| Field | Type | Description |
|---|---|---|
| block_toxic_input | boolean | Block hate speech, threats, violence, and harassment via LLM judge |
| block_prompt_injection | boolean | Block jailbreak and instruction-override attempts via LLM judge |
| block_pii_input | boolean | Block messages containing CPF, credit card, or BR phone numbers |
| input_blocked_keywords | string[] | Block user messages containing any of these keywords (exact match) |
| input_blocked_patterns | string[] | Block user messages matching any of these regex patterns |
| input_safe_response | string | Message returned when input is blocked. Falls back to safe_response if empty. |
PUT /guard/configs/:id
Update a Guard config.
DELETE /guard/configs/:id
Delete a Guard config.