Before You Begin
You need an ABV API key to use guardrails. Sign up at app.abv.dev and create a new API key from your account settings.
Installation
Install the ABV client library for your language:- TypeScript/JavaScript
- Python
Your First Validation
Letβs check if a user message contains toxic content. This is one of the most common uses of guardrails since it protects both your LLM from poisoned context and your users from harmful responses.- TypeScript/JavaScript
- Python
Understanding What Just Happened
You sent content to the guardrail
Your code called the toxic language guardrail with the message text and a sensitivity setting of βmediumβ. This sensitivity level catches clear violations while allowing professional disagreement.
The guardrail analyzed the content
The guardrail used an LLM to understand the context, tone, and intent of the message. Unlike keyword filters, it understands that βI disagreeβ is different from βYouβre an idiot.β
You received a structured result
The result contains three key pieces: status (pass/fail/unsure), confidence (0.0-1.0), and reason (human-readable explanation). This structure is consistent across all guardrails.
ABV automatically created an observation
Without any additional code, the guardrail check was logged to your ABV dashboard. You can now view the input, output, confidence score, and timing information.
Making Decisions with Results
Youβll typically use the status field to make decisions in your code:- TypeScript/JavaScript
- Python
Common Validation Scenarios
Validating LLM Outputs
Guardrails work equally well for checking LLM-generated content before you show it to users. This helps maintain brand safety and compliance:- TypeScript/JavaScript
- Python
Working with Structured Outputs
If your LLM generates JSON, you can validate both the format and schema in one step:- TypeScript/JavaScript
- Python
Running Multiple Guardrails
Youβll often want to check content against multiple criteria. Run guardrails in parallel to minimize latency:- TypeScript/JavaScript
- Python
Monitoring Your Guardrails
Every time you run a guardrail, ABV automatically creates an observation in your dashboard. This lets you:- Monitor how often guardrails are failing
- Analyze what reasons theyβre giving
- Track confidence score distributions
- Tune sensitivity settings based on real data
- Identify patterns in validation results
Next Steps
Core Concepts
Learn how sensitivity levels and confidence scores work across all guardrails
Best Practices
Discover optimal patterns for combining guardrails and handling errors
Toxic Language
Deep dive into toxic language detection and sensitivity levels
Biased Language
Explore bias categories and how to check for discriminatory content
Valid JSON
Master schema validation and strict mode for structured outputs
Contains String
Use rule-based checks for maximum performance with instant validation