Skip to main content
pip install validate-llm

PyPI Python Docs License

Bring your own LLM — validate-llm wraps it with configurable input and output guardrails. Pass any provider and model (Anthropic, OpenAI, Gemini, and 100+ more), and get structured validation results for toxicity, privacy, accuracy, relevancy, and bias.

Documentation →


Install

pip install validate-llm

Requires Python 3.11+.

Quick start

from llm_validation_framework import ValidationFramework, LLMProvider, Pipe
from llm_validation_framework import ToxicityAgent, PrivacyAgent, AccuracyAgent
from llm_validation_framework.config_loader import load_api_key

llm = LLMProvider(provider="anthropic", model="claude-haiku-4-5-20251001", key=load_api_key())

vf = ValidationFramework(
    llm=llm,
    input_guardrail=Pipe(steps=[ToxicityAgent()], verbose=False),
    output_guardrail=Pipe(steps=[ToxicityAgent(), PrivacyAgent(), AccuracyAgent()], verbose=False),
)

result = vf.validate("What is the Pacific Ocean?")
print(result["status"], result["score"])  # PASS 0.87

validate() returns a structured dict with status, score, and per-agent results for both the input and output guardrails. See the docs for the full schema.

Demo

The demo is a FastAPI backend + static web UI.

# Terminal 1
uvicorn demo.api_server:app --host 127.0.0.1 --port 5050

# Terminal 2
python demo/serve_ui.py

Open http://127.0.0.1:8000.

Agents

Agent What it does Needs API key
ToxicityAgent Three-layer check: profanity filter → toxicity model → semantic similarity No
PrivacyAgent Regex scan for SSN, credit cards, API keys; optional system prompt leakage detection No
AccuracyAgent LLM-as-a-judge factual accuracy + relevancy, with optional RAG grounding Yes
RelevancyAgent LLM-as-a-judge check that the answer addresses the question Yes
BiasAgent LLM-as-a-judge scan for stereotypes and discriminatory language Yes

ToxicityAgent and PrivacyAgent run fully locally with no external calls.

Config

Set the API key for your chosen provider:

export ANTHROPIC_API_KEY=your-key   # Anthropic (default)
export OPENAI_API_KEY=your-key      # OpenAI
export GEMINI_API_KEY=your-key      # Google

Or create a config.ini at the repo root (gitignored):

[ANTHROPIC]
API_KEY=your-key

[OPENAI]
API_KEY=your-key

Any provider supported by litellm works. Pass provider= and model= to any LLM-as-a-judge agent to switch:

AccuracyAgent(provider="openai", model="gpt-4o-mini")
BiasAgent(provider="gemini", model="gemini-2.0-flash")

RAG grounding

Pass a retriever to AccuracyAgent to ground factual checks against your own corpus:

from llm_validation_framework import AccuracyAgent, RAGProvider

accuracy = AccuracyAgent(rag=RAGProvider(your_vectorstore.as_retriever()))

See the RAG Integration guide for a full walkthrough.

Contributors

  • Hitha Shri Nagaruru
  • James Wu
  • Lewis Lui
  • Thomas Yeoh

License

MIT — see LICENSE

Metadata

Release files for validate-llm 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for validate-llm 0.1.3
File Size Uploaded
validate_llm-0.1.3.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for validate-llm 0.1.3
File Interpreter ABI Platform
validate_llm-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 38.0 kB

Release files / validate_llm-0.1.3.tar.gz

Download URL validate_llm-0.1.3.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5e896a99ecfc1a2c06282c1750718a334a469cb3d9a17d693e4c7a4476b553a8
BLAKE2b-256 checksum
How to use checksums
fc5761dd736d9ee69e022e41a25507edd3d76617f0da77ab579cb4834e696398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / validate_llm-0.1.3-py3-none-any.whl

Download URL validate_llm-0.1.3-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a75fe3540610c778409dac4dc82901bcd28d5d15d3dd9c3b542679959a59b7c
BLAKE2b-256 checksum
How to use checksums
a41eca23189636a8f3f292e7fd115b05efe8f2bcdba65c34217d57ca4079a953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page