Overview
The official LangChain integration provides native middleware for AI governance, compliance, and human-in-the-loop workflows. Add enterprise-grade controls to your LangChain agents with zero modifications to your existing code.Key Features
Guardrail Middleware
Policy-based validation of agent responses (GDPR, EU AI Act, Bias & Fairness)
Human-in-the-Loop
Approval workflows for sensitive tool calls with multi-channel routing
Dashboard Configuration
All policies configured in Velatir Dashboard - no code changes needed
Smart Routing
Low-risk actions approved instantly, high-risk routed to humans
Installation
Quick Start
Guardrail Middleware
Validate agent responses through Velatir’s policy engine:Human-in-the-Loop Middleware
Require approval before executing tool calls:How It Works
Guardrail Flow
Human-in-the-Loop Flow
Configuration
All policies and flows are configured in your Velatir Dashboard - no code changes needed when updating policies.Middleware Options
VelatirGuardrailMiddleware
VelatirGuardrailMiddleware
Parameters:
api_key
(required): Your Velatir API keymode
:"blocking"
or"logging"
(default:"blocking"
)approval_timeout
: Max seconds to wait for decision (default: 30.0)polling_interval
: Seconds between status checks (default: 2.0)blocked_message
: Custom message when response is blockedmetadata
: Additional context for review tasks
- blocking: Stops execution when Velatir denies response
- logging: Logs decisions but continues execution
VelatirHITLMiddleware
VelatirHITLMiddleware
Parameters:
api_key
(required): Your Velatir API keytimeout
: Max seconds to wait for approval (default: 600.0)polling_interval
: Seconds between status checks (default: 5.0)require_approval_for
: Optional list of tool names to checkmetadata
: Additional context for review tasks
- If
require_approval_for
isNone
: All tools are evaluated - If specified: Only listed tools go through Velatir
Real-World Examples
Content Moderation Agent
Financial Transaction Agent
Combined Guardrails + HITL
Policy Configuration
Configure policies in your Velatir Dashboard without touching code:GDPR Policy
Ensure compliance with GDPR requirements
EU AI Act Policy
Align with EU AI Act regulations
Bias & Fairness
Detect and prevent bias in responses
Custom Policies
Create organization-specific policies
Approval Channels
Human reviewers can approve/deny requests through multiple channels:Slack
Approve from Slack channels
Microsoft Teams
Teams integration for approvals
Email-based review workflow
Web Dashboard
Centralized approval dashboard
Advanced Usage
Custom Metadata
Add context to help with routing and decision-making:Error Handling
Async Support
Both middlewares fully support async operations:Installation & Documentation
langchain-velatir on PyPI
Complete package with examples and type hints
GitHub Repository
Source code, examples, and issue tracking
Supported Python Versions
- Python 3.10+
- Python 3.11
- Python 3.12
- Python 3.13
Requirements
velatir>=1.0.0
- Velatir Python SDKlangchain-core>=0.3.0
- LangChain core librarypydantic>=2.0.0
- Data validation