Skip to main content

Python SDK for TraceLedger — immutable audit trails for AI agent decisions

Project description

TraceLedger Python SDK

Immutable audit trails for AI agent decisions.

Installation

pip install traceledger

Quick Start

from traceledger import TraceLedger

tl = TraceLedger(api_key="tlk_your_api_key_here")

with tl.trace(agent_name="my-agent", task_description="Process loan application") as trace:
    trace.anchor_input(
        data_type="loan_application",
        description="Applicant application data",
        data={"applicant_id": "APP-1234", "amount": 450000}
    )

    trace.capture_decision(
        decision="Approved at 5.2% APR",
        reasoning="DTI ratio 28%, credit score 740, stable employment",
        alternatives=["Deny", "Approve at higher rate"],
        confidence="high"
    )

    trace.anchor_output(
        output_type="loan_decision",
        description="Loan approval with terms",
        data={"decision": "approved", "apr": 5.2}
    )

Every trace entry is cryptographically hash-chained. The audit trail is immutable and independently verifiable.

Features

  • Session-scoped traces via context manager — automatic session_start/session_end
  • Decision capture with reasoning, alternatives, and confidence
  • Input/output anchoring — record what data went in and what came out
  • Tool call tracking — record external API calls and their results
  • Reasoning steps — capture the evidence chain as it's built
  • Hash-chained immutability — every entry is cryptographically sealed

API Reference

TraceLedger(api_key, base_url, timeout)

Initialize the client.

  • api_key (str): Your API key (starts with tlk_).
  • base_url (str): API URL. Defaults to https://app.traceledger.io.
  • timeout (float): Request timeout in seconds. Defaults to 30.

TraceLedger.trace(agent_name, agent_version, task_description, metadata)

Returns a TraceSession context manager.

TraceSession methods

  • capture_decision(decision, reasoning, alternatives, confidence) — Record a decision
  • anchor_input(data_type, description, data) — Record input data
  • anchor_output(output_type, description, data) — Record output/artifact
  • capture_tool_call(tool_name, arguments, result) — Record a tool call
  • capture_reasoning(step, observation, conclusion, evidence) — Record a reasoning step

License

MIT — TraceLedger, Inc.

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

traceledger-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

traceledger-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for traceledger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6ebebf6962f9d939a1cc212a2c09b4469975bad3674484ef5b435e9f63072b2
MD5 1f841baca58a1b22a8077f289460e411
BLAKE2b-256 2e59b65d5a13fc6eea3892ec947659f8e32e594efa47f7cd38229d5135da88cc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for traceledger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9931ede9316c1d278e71c916ce0113fdc244e07879a6f35c355a10559adecc14
MD5 29a6cd0f21cefb124e30aa5330fb7905
BLAKE2b-256 5255c2b1624d34ba7553bd0c25c19b19da51fc64ac60dcdba25f6526ed01696c

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