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.4.tar.gz (4.9 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.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hallutraceai-0.1.4.tar.gz
  • Upload date:
  • Size: 4.9 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.4.tar.gz
Algorithm Hash digest
SHA256 ef372ca38192d2fed5b626adeedf5e174f0708945e197d5d609dbe587eb40cb7
MD5 730f97c94252878a883a549f01c36021
BLAKE2b-256 f08bdf589492c4bbd5d0b16a668479d62296ae749a9b8913e8371dbbd180c712

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hallutraceai-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a5459386ed165f5c5658e1321c2a7493baa66291946e59aa6bd5c734c4cc5ae9
MD5 b4746f04c9b539bb57356d63d69d658b
BLAKE2b-256 f662f1936f9e78f2f27dbd2cfd981e1ddab87f5524e1a2a4b7e1f26034c64599

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