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.0.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.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hallutraceai-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 b9f10c7b82fe09d6e5308e8784e7c385f7b8249df6be1b44165d16a14ecda7a7
MD5 3d2df71a8558ead0c5ed1d3925124b1e
BLAKE2b-256 1c02ebce6fda27a0132004bacfb6a04774ec0ef35e68279d8bb097a49a2ce768

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hallutraceai-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25eff7e545205f3ac481aa05de79c861893dea0a3a64acdd1e57097cbc42f917
MD5 3c9bc5d21a16fa6515087053ed678689
BLAKE2b-256 4388c79e7cac4f9adef149974e1c6e704b79bb92fe230f60dc8d89e72f3e50aa

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