Skip to main content
Let your agent set this up. Copy the evaluations prompt into your coding agent to get started automatically.
This guide shows how to integrate guardrails into your application using the LangWatch SDK. Guardrails run evaluators synchronously and return results you can act on immediately.

Basic Usage

The key difference between guardrails and regular evaluations is the as_guardrail=True parameter, which tells LangWatch this evaluation should block if it fails.

Guardrail Response Structure

When you run a guardrail, you get back a result object with these fields:

Input vs Output Guardrails

Input Guardrails

Check user input before calling your LLM:

Output Guardrails

Check LLM response before returning to user:

Combined Guardrails

Use both for comprehensive protection:

Async Guardrails

For async applications, use async_evaluate:

Parallel Guardrails

Run multiple guardrails in parallel to reduce latency:

Custom Guardrails with LLM-as-Judge

Create custom guardrails using LLM-as-Judge evaluators:

Error Handling

Always handle potential errors in guardrail execution:

Configuring Evaluator Settings

Many evaluators accept custom settings:

Next Steps

Guardrails Overview

Evaluators List

Python SDK Reference

TypeScript SDK Reference