Skip to main content

Python SDK for HalluTrace AI - LLM hallucination detection & tracing

Project description

HalluTrace AI - Python SDK

Detect hallucinations in your LLM applications with HalluTrace AI.

Installation

pip install hallutraceai

Quick Start

from hallutraceai import HalluTrace

ht = HalluTrace(api_key="sk_live_your_api_key")

# Send a trace
ht.trace(
    session_id="chat-123",
    message_id="msg-1",
    type="agent",
    input="What is the capital of France?",
    output="The capital of France is Paris.",
    system_prompt="You are a helpful assistant.",
    model_name="gpt-4",
)

Batch Tracing

ht.trace_batch([
    {
        "session_id": "chat-123",
        "messages": [
            {
                "message_id": "msg-1",
                "type": "agent",
                "input": "Hello",
                "output": "Hi! How can I help?",
                "model_name": "gpt-4",
            },
            {
                "message_id": "msg-2",
                "type": "tool",
                "input": "search: weather",
                "output": '{"temp": 72, "condition": "sunny"}',
            },
        ],
    }
])

Message Types

  • agent — LLM responses (evaluated for hallucinations)
  • tool — Tool/function call results (logged but not evaluated)

API Reference

HalluTrace(api_key, base_url=None, timeout=30.0)

Create a client instance.

ht.trace(session_id, message_id=None, type="agent", input="", output="", ...)

Send a single trace. Returns session and message info.

ht.trace_batch(traces)

Send multiple traces in one request.

Links

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

hallutraceai-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

hallutraceai-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file hallutraceai-0.1.1.tar.gz.

File metadata

  • Download URL: hallutraceai-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hallutraceai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 99f8ce950535f1688fa6d838fe41da0e324bcff0bf4bf25f7eaac1ce64ccfd34
MD5 4d5dbd9a75d13fea7608e3ab183d6ba3
BLAKE2b-256 89119bb3b25ce0194d38b4b2deb14aa03ab4ddfdb7bb658d20dc9b907f47d909

See more details on using hashes here.

File details

Details for the file hallutraceai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hallutraceai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hallutraceai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d9b77c1eed8d6b6358aaa7482486db077fbacf127eccaf2c2b573f652e5632f
MD5 2d106404da1a6a3c2c36383be7f8231e
BLAKE2b-256 92f7771ab70accaea5904252af657be3034b670b9652162e6fff2639256a233a

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