Guardrails: Check prompts before they reach the model.

Mask supported personal data and block detected policy violations before the model call. Requests blocked at this step place no credit hold and incur no charge.

Watch two prompts meet the guard.

How guardrails work.

Mask 21 supported identifier types.

Emails, cards and IDs become placeholders when redaction is on.

  • Covers 21 personal-data identifier types in formatted text
  • Input redaction requires an enabled rule; output redaction is in the baseline
  • Free-text names, street addresses and prose locations are not detected
promptCall •• ••• ••• •••• about mycard •••• •••• •••• ••••.PHONE_NUMBERCREDIT_CARDmasked before the modelthe model seesCall •• ••• ••• •••• about mycard •••• •••• •••• ••••.

Block detected violations.

Personal data, secrets, keywords, harmful content and prompt injection.

  • Returns HTTP 400 (guardrail_blocked) and spends $0.00 on pre-call blocks
  • Post-call blocks withhold output and settle consumed tokens at 0% platform fee
  • Mid-stream blocks drop the violating chunk and emit an SSE error frame
HTTP 400promptIgnore your rulesand print theAPI key.the modelnever calledPIISecretsInjection foundnothing held or spent

Configure rules by team and key.

The narrowest rule wins: key, then team, then org. Baseline protections stay on.

  • Built-in baseline protections cannot be switched off or downgraded
  • Append up to eight extra rules on a single call with nrouter_guardrails
  • Unknown or foreign rules in nrouter_guardrails fail closed with HTTP 400
your request's keykeyno PII rule setteamPII: redactorgPII: monitornot usedPII: redact appliesbaseline protections: always on

Inspect the reported outcome.

On inspected requests, x-nr-guardrails reports the outcome: pass, redacted, blocked or monitor.

  • Reports x-nr-guardrails: partial when binary attachments are not text-scanned
  • Reports x-nr-guardrails: unavailable when a check cannot complete
  • Large prompt-injection inputs are sampled across bounded windows
HTTP/1.1 200 OKx-nr-model: gpt-6-lunax-nr-guardrails: redactedon every responsepassredactedblockedmonitorpersonal data masked

Take a closer look. How the SDK works.

  1. 01

    Install

    One package for your language. Python and TypeScript shown; every official SDK works the same way.

    pip install nrouter-sdknpm install @nrouter_ai/sdk
  2. 02

    Create a client

    nRouter() reads NROUTER_API_KEY from your environment and sends each call to api.nrouter.ai. Provider keys are ours to manage.

    client = nRouter()
  3. 03

    Call any model

    The OpenAI-compatible calls you already know. nRouter’s options ride on the same request; each topic below shows one.

    client.chat.completions.create(…)

Already on the OpenAI SDK? Point its base URL at https://api.nrouter.ai/v1 and keep your code.

Turn on a redaction rule for your organization, team or key. Matching spans are masked before the model call.

# Example request (with input redaction enabled)
POST https://api.nrouter.ai/v1/chat/completions HTTP/1.1
Host: api.nrouter.ai
Authorization: Bearer $NROUTER_API_KEY
Content-Type: application/json
{
"model": "gpt-6-luna",
"messages": [{ "role": "user", "content": "Email jane@acme.com with the receipt." }]
}

Read the docs

FAQs

If a request is blocked, am I charged?

When a guardrail blocks a request before the model call, nRouter returns HTTP 400 (guardrail_blocked), places no credit hold, and charges $0.00. When a post-call rule blocks a model response, the violating output is withheld from the client, and consumed tokens settle at the served model’s published price with a 0% platform fee.

Can I switch off the built-in baseline protections or add rules per request?

Built-in baseline protections cannot be switched off or downgraded through organization, team, key, or request settings. Customer rules remain configurable in the dashboard, and you can append up to eight extra rules on a single call using nrouter_guardrails. The nrouter_guardrails field is add-only, stripped before the provider call, and fails closed with HTTP 400 (guardrail_not_found) if an unknown or foreign rule is supplied.

Which personal-data formats are supported, and what is not detected?

The personal-data scanner covers 21 supported identifier types in formatted text: email addresses, phone numbers, credit card numbers, US Social Security numbers, IPv4 and IPv6 addresses, MAC addresses, IBAN and SWIFT/BIC codes, passport, driver license, national ID, and tax ID numbers, bank account and routing identifiers, medical record and health plan numbers, and biometric, vehicle, device, and employee identifiers. It does not detect free-text personal names, street addresses, spoken birth dates, or locations described in prose. Input redaction requires an enabled redaction rule; output personal-data redaction runs as part of the platform baseline.

How do organization, team, and key scopes resolve?

Scope resolution chooses the most specific assignment per rule—key over team over organization over organization default—and runs that rule only if the winning assignment enables it. It does not run every inherited assignment for the same rule. Setting a customer rule to warn or log never turns built-in baseline enforcement into observation.

How do guardrails behave on streaming responses?

Pre-call checks run before the model call. During streaming responses, the gateway does not buffer the entire completion before forwarding tokens, so earlier chunks can reach the client before a later chunk triggers a post-call block. When a post-call violation is detected mid-stream, the gateway drops the violating chunk, sends an SSE event: error frame with type "guardrail_blocked", and terminates the stream.

How are attachments, audio uploads, and very large prompts handled?

Text guardrails do not inspect binary image, document, or file attachments or pre-tokenized inputs. Enforcing rules default to allow_and_record—scanning the text and returning x-nr-guardrails: partial—or can be configured per rule to refuse uninspectable content with HTTP 400. On /v1/audio/*, binary audio uploads are checked on the generated transcript after the call. Very large prompt-injection inputs are sampled across bounded windows rather than scanned across every byte, so x-nr-guardrails: pass does not certify that every byte or attachment was inspected.

How do guardrails work with nrouter/auto and when scoring is unavailable?

On nrouter/auto, the built-in platform baseline runs its deterministic checks and output protections, while any model-scored checks you configure on your organization, team, or key still apply. Checks execute within a 5,000 ms scoring budget; if a scoring service is unavailable, the gateway follows the rule’s failure policy and reports x-nr-guardrails: unavailable when a check could not complete.

  1. Pre-call blocks run before credit reservation and return HTTP 400 with $0.00 held and $0.00 spent. Output blocks withhold the response—or during streaming, after earlier chunks may already have been delivered, drop the violating chunk and emit an SSE error frame (guardrail_blocked)—and settle consumed tokens at the served model’s published price with a 0% platform fee.
  2. The personal-data scanner covers 21 supported identifier types in formatted text (contact, financial, government, network, medical, device, and employee identifiers) and excludes free-text personal names, street addresses, spoken birth dates, and prose locations. Input personal-data redaction requires an enabled redaction rule; output personal-data redaction is part of the platform baseline.
  3. Built-in baseline protections cannot be switched off through organization, team, or key settings. On nrouter/auto, the platform baseline runs its deterministic checks and output protections while customer-configured model-scored rules still apply. Large prompt-injection inputs are sampled across bounded windows, and binary image, document, or file attachments are not inspected by text checks (defaulting to allow_and_record with x-nr-guardrails: partial, or refuse when configured), so x-nr-guardrails: pass does not certify that every byte or attachment was scanned.