API Reference

Guard

Reliant Guard is an AI conversation guardrails layer. It sits between your user and any AI — validating responses against Topic, Data Shield, and Tone rules before delivery. One API call replaces fragile prompt engineering with runtime enforcement.


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.

http
POST /guard/chat X-Reliant-Key: rel_... Content-Type: application/json

Body

json
{ "user_message": "What's the price of your competitor?", "guard_id": "guard_ffd3913d70d48f029e8cf5f2", "user_id": "your-user-id" }
FieldTypeRequiredDescription
user_messagestringyesThe message sent by the end user
guard_idstringyesGuard config ID created in Dashboard → Guard
user_idstringyesYour User ID (Dashboard → Settings)
Provider and model are configured once in the Guard config — not passed per request. This keeps your integration minimal and your bot code clean.

Response

json
{ "allowed": false, "response": "I can only help with questions about our product.", "blocked_by": "topic", "block_reason": "Response discusses competitor pricing", "provider": "anthropic", "model": "claude-haiku-4-5-20251001", "guard_id": "guard_ffd3913d70d48f029e8cf5f2", "latency_ms": 312 }
FieldTypeDescription
allowedbooleanWhether the response passed all guard layers
responsestringThe final response to deliver to the user. Safe response if blocked.
blocked_bystring | nulltopic, data, tone, or null if allowed
block_reasonstring | nullHuman-readable explanation of why it was blocked
latency_msnumberTotal latency including AI call and all validation layers

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.

json
{ "ai_response": "The AI-generated message to validate", "user_message": "What the user originally asked", "guard_id": "guard_ffd3913d70d48f029e8cf5f2", "user_id": "your-user-id" }

Guard layers

◎ 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.

regex examples
// CPF (Brazil) \d{3}\.\d{3}\.\d{3}-\d{2} // Credit card \d{4}[\s-]\d{4}[\s-]\d{4}[\s-]\d{4} // Email [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

◈ 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:

javascript
// In your webhook handler (n8n, Make, or custom code) app.post('/webhook/whatsapp', async (req, res) => { const userMessage = req.body.message.text const userId = req.body.user.id // Single call — Guard handles AI + validation const guard = await fetch('https://reliant-production.up.railway.app/guard/chat', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Reliant-Key': process.env.RELIANT_API_KEY, }, body: JSON.stringify({ user_message: userMessage, guard_id: process.env.GUARD_ID, user_id: process.env.RELIANT_USER_ID, }), }) const result = await guard.json() // result.response is always safe to send // If blocked: result.response = your configured safe_response // If allowed: result.response = validated AI response await sendWhatsAppMessage(userId, result.response) res.json({ ok: true }) })
Tip: The 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.

FieldTypeDescription
max_executions_per_periodnumberMax executions for the whole project per period
period_typestringhourly, daily, or monthly
limit_responsestringResponse returned when project limit is reached
max_executions_per_usernumberMax executions per end-user per period
user_period_typestringhourly, daily, or monthly
user_limit_responsestringResponse 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.

json — /guard/chat with end_user_id
{ "user_message": "What are your business hours?", "guard_id": "guard_...", "user_id": "your-user-id", "end_user_id": "+1-555-0100" // phone, user ID, or session token }

When a limit is hit, the response looks like this:

json — limit reached response
{ "allowed": false, "response": "You've reached your daily limit. Please try again tomorrow.", "blocked_by": "user_limit", "block_reason": "User limit reached: 50/50 per day", "guard_id": "guard_...", "latency_ms": 0 }
Zero cost when blocked. Limit checks run before the AI is called — so a blocked request costs nothing in tokens.

GET /guard/usage/:guard_id

Returns current period usage for a Guard — project total and top end-users by volume.

json — response
{ "period": "2026-05", "project_total": 8432, "top_users": [ { "end_user_id": "+1-555-0100", "count": 142, "period": "2026-05" }, { "end_user_id": "+1-555-0101", "count": 98, "period": "2026-05" } ] }

Guard config endpoints

GET /guard/configs

List all Guard configs for the authenticated project.

POST /guard/configs

Create a Guard config programmatically.

json
{ "name": "Customer Support Bot", "provider": "anthropic", "model": "claude-haiku-4-5-20251001", "allowed_topics": ["product support", "billing", "technical help"], "blocked_topics": ["competitors", "pricing details"], "blocked_keywords": ["password", "secret", "token"], "tone_rules": "Always be empathetic and professional. Never use aggressive language.", "safe_response": "I can only help with questions about our product.", "user_id": "your-user-id" }

PUT /guard/configs/:id

Update a Guard config.

DELETE /guard/configs/:id

Delete a Guard config.