Feature  ·  Guardrails

Stop bad outputs before they reach users.

7 guardrail types run inline on every LLM request — block, warn, redact, or log. PII, toxicity, topic drift, format, cost ceiling, and custom rules.

Pre-call and post-call phases. Configurable per agent. Live test before deploying.

Start free →View docs
Zespan Guardrails
Works withPre-call phasePost-call phaseAgent filterRegexLLM judgePII redaction

7

types

4

actions

50ms

min latency cap

1.0  Guardrails

7 Guardrail Types

What you get

PII, Toxicity, Topic Boundary, Format, Cost Ceiling, Custom LLM, RegexPhase: pre (before LLM call), post (after response), or bothPriority 0–100: controls execution order when multiple guardrails apply

PII detects and redacts personal data. Toxicity blocks harmful content. Topic boundary prevents scope creep. Format enforces output structure. Cost ceiling blocks expensive requests. Custom LLM uses your own judge prompt. Regex handles exact pattern matching.

Zespan guardrail configuration showing types, actions, and phase settings

2.0  Guardrails

4 Actions: Block, Warn, Redact, Log

What you get

Block: throws GuardrailBlockedError — handle in your catch blockRedact: matching content removed, modified text returned in result.modifiedTextWarn / Log: zero user-visible impact, full audit trail

Block rejects the request and returns a GuardrailBlockedError. Warn logs the issue and allows through. Redact removes matching content and allows the modified text through. Log records without interfering.

3.0  Guardrails

Live Test Before Deploying

What you get

Test with draft config: preview guardrail behavior without savingApply guardrails in Playground: validate prompt safety interactivelyPer-guardrail latency cap (50ms–30s): slow guards never block requests

Pass any draft guardrail config and arbitrary input text to the live test endpoint — no save required, no deployment needed. See exactly what would be blocked, warned, or redacted before it goes live.

4.0  Guardrails

Execution Logs & Metrics

What you get

Per-check log: queryable by guardrail ID, result, and time rangeResult caching: repeated identical inputs skip re-evaluation via CacheLayerAudit log: create/update/enable/disable events with actor user ID and IP

Every guardrail check is logged: slug, passed/failed, action taken, reason, modified text, and latency. Time-range metrics (pass/block/warn/redact rates) available for 24h, 7d, 30d. All config changes written to audit log.

Setup

Under 5 minutes,
two lines of code.

No forking and no architecture changes. Traces appear within seconds of the first agent run, with cost attribution, eval scores, and anomaly alerts on by default.

typescript
import { Zespan } from '@zespan/sdk';

const lt = new Zespan({ apiKey: process.env.ZESPAN_API_KEY });

// Guardrail check — configured in dashboard, enforced by SDK
try {
  const result = await lt.guardrails.check({
    input: userMessage,
    projectId: 'your-project-id',
  });
  // result.passed, result.action, result.modifiedText
} catch (err) {
  if (err instanceof GuardrailBlockedError) {
    return { blocked: true, reason: err.reason };
  }
}

Common questions

Do guardrails add latency to my LLM calls?

Only pre-call guardrails add latency — they run before the LLM call. Post-call guardrails run after and don't affect your response time. For pre-call guards, you can configure a max latency cap (50ms–30s) so a slow guardrail never blocks the request.

What happens when a guardrail blocks a request?

The SDK throws a GuardrailBlockedError with a reason field. Catch this error in your application and handle it — return a fallback response, log it, or show the user an appropriate message.

Can I scope a guardrail to only apply to certain agents?

Yes. Each guardrail has an agent filter field — set it to specific agent names and that guardrail only runs for those agents. Different agents can have different safety rules on the same project.

What's the difference between a custom LLM guardrail and a regex guardrail?

Regex guardrails use pattern matching — they're fast (sub-millisecond) and deterministic, ideal for exact strings, known PII formats, or prohibited phrases. Custom LLM guardrails use an LLM as judge — slower but understand context, semantics, and nuance. Use regex for rules you can fully specify; use custom LLM for rules that require judgment.

Are guardrail results cached?

Yes. Guardrail results are cached by input hash via CacheLayer. If the same input is seen again, Zespan returns the cached result without re-running the check — saving latency and LLM judge costs on repeated inputs.

Explore more features

All features →
TracingSee exactly what your agents are doing.Every LLM call, agent step, and tool invocation captured as a structured trace — with cost, latency, and tokens per span.Agent MonitoringKnow which agents are healthy, and which aren't.Composite health scores, delegation graphs, and per-agent cost attribution — built for systems with many cooperating AI agents.EvaluationsMeasure output quality on every trace, automatically.12 built-in LLM-as-judge templates run on every new trace with no setup. Track quality trends, catch regressions, and run manual eval campaigns.Prompt ManagementShip prompt changes without breaking production.Version history, production promotion, automatic regression detection after every deploy, and AI-powered optimization suggestions.

Your agents are running.
Do you know what they’re doing?

Observe, evaluate, guard, and control every agent, live in minutes. No credit card required.

Free tier availableUnder 5 min setupNo credit card