Skip to main content

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:

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 syntax
  • regex - Pattern matching
  • schema - JSON schema validation
  • length - Output length bounds

🔑 Requires API Key (Anthropic or OpenAI)

  • hallucination - Detect made-up facts
  • factuality - Check factual accuracy
  • relevance - Relevance to input
  • toxicity - Harmful content detection
  • bias - Bias/fairness issues
  • pii - Personal information detection
  • consistency - Internal consistency
  • contradiction - Logical contradictions
  • groundedness - 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:

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

ai_qa_sdk-0.2.0.tar.gz (112.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_qa_sdk-0.2.0-py3-none-any.whl (71.2 kB view details)

Uploaded Python 3

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

Hashes for ai_qa_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c1b4271c4a2c6739478197827a59f53d5163c64877d280a81d516b55dde6700f
MD5 3037533c9a293c0ed9c010a549f971af
BLAKE2b-256 eef84afdf526c74bc53dd80d51a41e37b3b09b1175b59464841d44fad2616081

See more details on using hashes here.

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

Hashes for ai_qa_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62bc9cbf65d3a60e2f184854948b2991bc1699fedab9f5f989b58bd2c610b680
MD5 f36d7e44e5d16b7f5239fbe0e1e593ae
BLAKE2b-256 f93a82c99cd15b1928002ab83353f28027366a1cb03ae37cf43dfd602c60cd03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page