Customer Support
Support bots with guardrails built in.
Redact customer PII and block prompt injection on every request, keep tone consistent with versioned templates, and cap spend with budgets.
Safety, consistency, and cost control.
Protect customer data, block hostile inputs, keep replies on-brand, and cap monthly bot spend.
PII redaction on every message
Emails, phones, SSNs, credit cards, and IP addresses are masked before prompts leave the gateway.
- 21 kinds of personal data, each set to block or redact
- Card numbers must pass the Luhn checksum, so order IDs stay intact
- Every match is recorded in Guardrails → Logs
Prompt-injection and jailbreak defense
Jailbreak and instruction-override patterns are blocked before the provider call with $0 spent.
- A blocked prompt returns 400 with x-nr-guardrails: blocked
- No credit hold and no provider call on a pre-call block
Versioned prompt templates
Keep tone and escalation rules in central templates. Test variations or roll back without redeploys.
Explore prompt templatesBudgets and response caching
Per-key and per-team budgets cap spend with a hard 402 ceiling, while caching serves repeat questions.
- Byte-identical repeats are billed at the cache-read input rate
- Matching is exact, never semantic: a reworded question is a new call
A standard chat call, guardrails included.
Call the chat endpoint with your bot’s virtual key; inline guardrails inspect every turn.
pip install openai| 1 | # Cache: enabled (org default). Pass nrouter_cache: false to skip. |
| 2 | from openai import OpenAI |
| 3 | import os |
| 4 |
|
| 5 | client = OpenAI( |
| 6 | api_key=os.environ["NROUTER_API_KEY"], |
| 7 | base_url="https://api.nrouter.ai/v1", |
| 8 | ) |
| 9 |
|
| 10 | response = client.chat.completions.create( |
| 11 | model="gpt-5.4-mini", |
| 12 | temperature=1, |
| 13 | max_completion_tokens=1024, |
| 14 | messages=[ |
| 15 | {"role": "user", "content": "Hello! What models do you support?"}, |
| 16 | ], |
| 17 | extra_body={ |
| 18 | # "nrouter_cache": False, # Uncomment to skip cache |
| 19 | }, |
| 20 | ) |
| 21 |
|
| 22 | print(response.choices[0].message.content) |
FAQs
How does nRouter protect customer PII in support conversations?
When a PII redaction rule is enabled for your organization, team, or key, it runs as an inline guardrail filter on each request: it detects and masks email addresses, phone numbers, SSNs, credit-card numbers, and IP addresses before the prompt reaches the model. Output PII handling on responses is described in the guardrails docs.
Can guardrails block prompt-injection attempts from customers?
Yes. A prompt-injection detection guardrail inspects every inbound message for jailbreak, roleplay bypass, and instruction-override patterns. Detected injection patterns are blocked before they reach the foundation model — the gateway returns a guardrail_blocked error to your application, which chooses the customer-facing reply — and the attempt is logged in the security audit ledger.
How do response caching and tier routing reduce customer support costs?
Customer support traffic is heavily repetitive. nRouter caches responses at the gateway: a byte-identical repeat request is served from the cache instead of the model, and metered at the lower cache-read rate rather than the full input rate. Uncached queries can go to a fast, low-cost model, so the expensive model only sees the questions that need it.
How does multi-provider failover keep support bots online 24/7?
If an upstream foundation model provider rate-limits (429), is overloaded (503), fails to connect, or does not start responding in time, nRouter fails the request over to the next provider in your routing chain instead of surfacing the error. Your support bot fails over to your next model when a provider is rate limited or unavailable.
Can I enforce hard monthly budget limits on customer support bots?
Yes. Each support bot operates under a dedicated virtual key with strict hard budget caps. When monthly allocations are exhausted, the gateway returns HTTP 402 rather than incurring surprise overdrafts. Budget alerts can warn your operations team before the cap is reached.