Universal AI validation SDK — hallucination, factuality, safety checks for any LLM output
Project description
ai-qa-sdk
Python SDK for validating AI outputs.
Installation
pip install ai-qa-sdk
This installs everything you need including support for Anthropic (Claude) and OpenAI (GPT).
Quick Start
1. Deterministic Checks (No API Key Needed)
from ai_qa import validate
# Validate JSON format - works immediately!
result = validate(
output='{"name": "John", "age": 30}',
checks=["json_format"]
)
print(f"Passed: {result.passed}")
for check in result.checks:
print(f" {check.name}: {check.score:.2f}")
2. LLM-Powered Checks (Configure Your Provider)
Get an API key first:
- Anthropic (Claude): https://console.anthropic.com → API Keys
- OpenAI (GPT): https://platform.openai.com/api-keys
Then configure and use:
from ai_qa import configure, validate
# Configure your preferred provider
configure(provider="anthropic", api_key="sk-ant-YOUR-KEY-HERE")
# Or use OpenAI instead
# configure(provider="openai", api_key="sk-YOUR-KEY-HERE")
# Now you can use any LLM-powered check
result = validate(
output="The capital of France is Paris",
input="What is the capital of France?",
checks=["factuality", "relevance", "hallucination"]
)
print(f"Passed: {result.passed}")
print(f"Cost: ${result.total_cost:.4f}")
for check in result.checks:
print(f" {check.name}: {check.score:.2f}")
Available Checks
✓ No API Key Required
json_format- Validate JSON syntaxregex- Pattern matchingschema- JSON schema validationlength- Output length bounds
🔑 Requires API Key (Anthropic or OpenAI)
hallucination- Detect made-up factsfactuality- Check factual accuracyrelevance- Relevance to inputtoxicity- Harmful content detectionbias- Bias/fairness issuespii- Personal information detectionconsistency- Internal consistencycontradiction- Logical contradictionsgroundedness- Grounded in provided context- And more!
Providers
ai-qa-sdk supports multiple providers out of the box:
| Provider | Setup | Cost |
|---|---|---|
| Anthropic (Claude) | configure(provider="anthropic", api_key="...") |
~$0.003-0.015 per 1K tokens |
| OpenAI (GPT) | configure(provider="openai", api_key="...") |
~$0.03-0.06 per 1K tokens |
| Local (Ollama) | configure(provider="local", base_url="http://localhost:11434") |
Free (runs locally) |
Get API keys:
- Anthropic: https://console.anthropic.com/api-keys
- OpenAI: https://platform.openai.com/api-keys
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_qa_sdk-0.2.0.tar.gz.
File metadata
- Download URL: ai_qa_sdk-0.2.0.tar.gz
- Upload date:
- Size: 112.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1b4271c4a2c6739478197827a59f53d5163c64877d280a81d516b55dde6700f
|
|
| MD5 |
3037533c9a293c0ed9c010a549f971af
|
|
| BLAKE2b-256 |
eef84afdf526c74bc53dd80d51a41e37b3b09b1175b59464841d44fad2616081
|
File details
Details for the file ai_qa_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ai_qa_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 71.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62bc9cbf65d3a60e2f184854948b2991bc1699fedab9f5f989b58bd2c610b680
|
|
| MD5 |
f36d7e44e5d16b7f5239fbe0e1e593ae
|
|
| BLAKE2b-256 |
f93a82c99cd15b1928002ab83353f28027366a1cb03ae37cf43dfd602c60cd03
|