Skip to main content

Official Python SDK for AI Breaker Lab

Project description

aibreaker

Official Python SDK for AI Breaker Lab.

Install

pip install aibreaker

Quick start

from aibreaker import BreakerClient

client = BreakerClient(
    api_key="client_key",
    groq_api_key="gsk_...",   # forwarded to backend for test generation + judging
)

report = client.break_model(
    target={
        "type":       "openai",
        "base_url":   "https://api.openai.com",
        "api_key":    "sk-...",
        "model_name": "gpt-4o-mini",
    },
    description="Customer-support chatbot for an e-commerce platform",
    num_tests=20,
    fail_threshold=5.0,
)

print(report)
# Report a3f8b2c1  ✓ PASSED
#   Score         : 7.40 / 10
#   Failures      : 3 / 20
#   Hallucinations: 1
#   Agreement     : 100%
#   Red flags     : 0

if not report.passed:
    for f in report.failures:
        print(f"  ✗ [{f.test_type}] score={f.score}  {f.question}")
    raise SystemExit(1)

Supported target types

Type Required fields
openai base_url, api_key, model_name
huggingface repo_id, api_token
webhook endpoint_url, payload_template
langchain chain_import_path, invoke_key

Works with any OpenAI-compatible endpoint: Groq, Gemini, vLLM, Ollama, etc.

LangChain example

target = {
    "type": "langchain",
    "chain_import_path": "my_module.my_chain",  # must be importable by the backend
    "invoke_key": "question",
}

Report object

Attribute Type Description
report.score float Average weighted score (0–10)
report.passed bool True when score >= fail_threshold
report.failures tuple[FailedTest] Tests the model failed
report.failure_count int Number of failed tests
report.hallucination_count int Hallucinations detected
report.metrics Metrics Full metrics object
report.metrics.judges_agreement float Judge agreement rate 0–1
report.metrics.red_flags tuple[str] Auto-detected issues
report.html_report_url str | None URL to HTML report

Error handling

All SDK calls raise BreakerError when the backend returns a non-2xx response (e.g. 401/429/5xx) or when polling fails (timeouts, network errors).

from aibreaker import BreakerClient, BreakerError

client = BreakerClient(
    api_key="client_key",
    endpoint="https://llm-eval-engine-production.up.railway.app",
    poll_interval=5,  # seconds between GET /report/{id}
    timeout=600,      # total seconds to wait before giving up
)

try:
    report = client.break_model(
        target={
            "type": "openai",
            "base_url": "https://api.openai.com",
            "api_key": "sk-...",
            "model_name": "gpt-4o-mini",
        },
        description="Customer-support chatbot for an e-commerce platform",
        num_tests=20,
    )
except BreakerError as e:
    print(f"BreakerError: {e}")
    raise

print(report.score, report.passed)
Situation Exception How to handle
Invalid API key BreakerError (401) Check your api_key
Rate limited BreakerError (429) Reduce num_tests or wait
Job timed out BreakerError Increase timeout= param
Backend unreachable BreakerError Check endpoint= URL

timeout and poll_interval are set on BreakerClient(...). Increase timeout for long-running jobs (large num_tests, slow target, heavy load). Decrease poll_interval if you want more frequent status checks, but keep it reasonable to avoid extra load and 429s.

CI / CD

See the aibreaker GitHub Action for one-step CI integration.

- uses: your-org/aibreaker-action@v1
  with:
    api_key: ${{ secrets.BREAKER_API_KEY }}
    groq_api_key: ${{ secrets.GROQ_API_KEY }}
    endpoint: https://llm-eval-engine-production.up.railway.app
    description: "Customer support chatbot"
    fail_threshold: "5.0"

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

aibreaker-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

aibreaker-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file aibreaker-0.1.0.tar.gz.

File metadata

  • Download URL: aibreaker-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aibreaker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b5129c0ad407657d118f867e93f7cda93e49f5c362fa4a2dce5d421771750b8
MD5 45fd13e96922d6010b5592328250f2c2
BLAKE2b-256 74731206b4b842c0a90ce171a3e1281f62440e47592d6854a3da9f5df82918f2

See more details on using hashes here.

File details

Details for the file aibreaker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aibreaker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aibreaker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06f4a3edf0f6623572e2af43b414e06e23787c72862b5f84030d491813f1f2a2
MD5 634c216f0404c862e6677d7a6d784b96
BLAKE2b-256 a0a4dc17d29ebf26a23abc5cb9affee0dfaf7ae4abc875cf2709fac6cae91f1d

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