Skip to main content

Audit + reliability layer for AI agents. One call. Zero hallucinations in production.

Project description

helmric

Audit + reliability layer for AI agents.

One SDK call wraps any LLM output, cross-references every cited ID against the source data you gave the model, drops hallucinations, and writes an append-only audit trail.


Install

pip install helmric

Quickstart

from helmric import audit

result = audit.verify(
    output=llm_response_text,
    sources=[
        {"id": "user_123", "name": "Anna"},
        {"id": "user_456", "name": "Ben"},
    ],
    api_key="hk_live_...",   # or set HELMRIC_API_KEY env var
)

print(result.cleaned_output)   # LLM output with hallucinated IDs removed
print(result.hallucinated)     # ["d4e5f6a7-..."]  IDs the model invented
print(result.cited)            # ["user_123"]       IDs that actually grounded
print(result.audit_id)         # UUID of the audit row
print(result.audit_url)        # "https://helmric.com/audit/<id>"

API Key

Three resolution sources, in priority order:

  1. Explicit api_key= kwarg
  2. HELMRIC_API_KEY environment variable ← recommended for production
  3. ~/.helmric/config.toml with api_key = "hk_live_..."
export HELMRIC_API_KEY="hk_live_..."

Async

import asyncio
from helmric import audit

async def main():
    result = await audit.verify_async(
        output=llm_response,
        sources=[{"id": "doc_42"}],
    )
    print(result.hallucinated)

asyncio.run(main())

Error handling

from helmric import audit
from helmric.errors import HelmricAuthError, HelmricRateLimitError, HelmricError
import time

try:
    result = audit.verify(output=response, sources=sources)
except HelmricAuthError:
    print("Bad or revoked API key — check your HELMRIC_API_KEY")
except HelmricRateLimitError as e:
    time.sleep(e.retry_after)
    result = audit.verify(output=response, sources=sources)
except HelmricError as e:
    print(f"API error {e.status_code}: {e.detail}")

Parameters

audit.verify() / audit.verify_async()

Parameter Type Required Description
output str Raw LLM response text
sources list[dict] Source objects given to the model. Each must have an id key.
api_key str Helmric API key. Falls back to env var.
base_url str Override API base URL (for self-hosted).
model_provider str e.g. "openai". Stored in audit trail.
model_name str e.g. "gpt-4o". Stored in audit trail.
customer_request_id str Your correlation ID. Stored in audit trail.
timeout float Request timeout in seconds. Default 30.

VerifyResult fields

Field Type Description
cleaned_output str LLM output with hallucinated IDs removed
hallucinated list[str] IDs the model invented (not in sources)
cited list[str] IDs the model correctly cited (in sources)
audit_id uuid.UUID UUID of the append-only audit row
audit_url str Permalink to the audit event in the dashboard

Real-world example

import openai
from helmric import audit

client = openai.OpenAI()
sources = fetch_users_from_db(org_id)   # your data

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "Summarize team performance."},
        {"role": "user", "content": format_sources(sources)},
    ],
)
llm_text = response.choices[0].message.content

result = audit.verify(
    output=llm_text,
    sources=[{"id": str(u.id), "name": u.name} for u in sources],
    model_provider="openai",
    model_name="gpt-4o",
)

# Use result.cleaned_output in your product — hallucinations scrubbed.
# result.audit_url gives you a permanent link to the decision audit trail.

Requirements

  • Python 3.9+
  • httpx ≥ 0.27

License

MIT

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

helmric-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

helmric-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: helmric-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for helmric-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5223b2b748c07e7e86d687afda0f4b5c85a894e30ccc556c2150b23eaa6f26de
MD5 7585d64dd3137e2a4c78b42517c87eb7
BLAKE2b-256 ea7213706a1a9015b45ecc6b451ef24074e7d851608a801815258cc8efecb7e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: helmric-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for helmric-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbdd6f1f988b9f55926e8a806f4cafd516412b0caf2d37814f59fd2e8374694a
MD5 8dae6ee60a04fccd93a54becc50fb0d7
BLAKE2b-256 894707283d6144490aecd25c22ffe724b34bccafcdbeca128e60f2fe458b3ed6

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