BroadRouter
Get started

Guardrails

Updated

Guardrails are checks that an application runs around a language model call to keep it within set limits. Input guardrails screen what goes into the model, output guardrails check what comes out, and tool guardrails validate actions before they run. A failed check blocks, rewrites or flags the request.

Also called: LLM guardrails, AI guardrails, input guardrails, output guardrails, safety rails

Guardrails are the checks you wrap around a model so a bad input or a bad output stops at your code, not at your user.

How it works

The OpenAI Agents SDK describes guardrails as “checks and validations of user input and agent output” and defines three kinds:

Kind Runs Typical check
Input Before or alongside the first model call Off-topic, abusive or injected requests
Output After the final answer Leaked secrets, policy breaks, wrong format
Tool Before and after a function tool runs Arguments in range, no destructive action

When a check fails, a “tripwire” raises an exception and stops the run. Input checks can be blocking (the main model never starts) or parallel (lower latency, but tokens and tool calls may already be spent when the tripwire fires).

NVIDIA’s open-source NeMo Guardrails library uses five stages: input, retrieval, dialog, execution and output rails. Anthropic’s docs suggest a “harmlessness screen”: a small, fast model that classifies user input before it reaches the main conversation, with structured output so the verdict is a parseable true or false.

Not every guardrail needs a model. Regex filters, allow-lists, JSON Schema validation and length limits are cheap and deterministic.

Why it matters

  • Safety. Guardrails are one layer of defence against prompt injection and jailbreaks. No single layer stops all of them.
  • Cost. A cheap screen can reject a request before an expensive model reads 100,000 tokens of context.
  • Agents. An agent that sends email or edits data needs tool-level checks and human approval for high-risk steps, not only a filter on the final text.
  • Measure them. A guardrail that blocks good requests is a bug. Track false positives with an eval set.

On BroadNet Inference

BroadNet’s docs do not list guardrails, moderation endpoints or content filters. Treat guardrails as your application’s job. A common pattern is a screen on a smaller model such as BroadNet Gemma 4 VL 26B ($0.10 per 1M input tokens), then the main call on a larger model. If inputs contain personal data, see sending sensitive data to an LLM API.

Questions

Are guardrails part of the model?

No. Models have their own trained refusals, but guardrails are separate code or model calls that your application runs before and after the main call. You decide what they check.

Do guardrails add latency?

A blocking input check adds one extra call before the main model starts. The OpenAI Agents SDK can instead run input guardrails in parallel, which saves time but may spend tokens before the check trips.

Does BroadNet Inference include guardrails?

BroadNet's docs do not list guardrails or content filters as a feature. Build them in your application, for example with a small model as a screen and schema validation on outputs.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity