Skip to main content

Framework-agnostic, tamper-evident audit layer for AI agents. Hash chains verify byte-for-byte against the ProofLedger TypeScript SDK and dashboard.

Project description

ProofLedger Python SDK

A framework-agnostic, tamper-evident audit layer for AI agents. ProofLedger sits underneath or beside any agent framework (LangGraph, CrewAI, OpenAI Agents SDK, AutoGen, or a custom stack) and records every run, event, and tool call into a SHA-256 hash chain.

The chains this SDK produces are byte-for-byte compatible with the ProofLedger TypeScript SDK: runs captured from Python verify correctly in the ProofLedger dashboard, which verifies using the TS implementation.

No third-party runtime dependencies — standard library only (Python >= 3.9).

Install

pip install proofledger

Or from this repo:

pip install packages/sdk-py

Usage

from proofledger import enable, track, with_run, verify_run

# Cloud mode — sends to your ProofLedger backend.
enable(
    api_key="tl_live_...",
    base_url="https://proofledger.dev",
    project_id="proj_...",
)

# One-shot tracking of a complete, verifiable run.
track(
    agent_id="support-agent",
    input="Hello",
    output="Hi there",
    model="gpt-4.1",
    provider="openai",
)

If you call enable() without an api_key (or pass local=True), the SDK runs in local dev mode: events are kept in memory and best-effort appended to ./.proofledger/events.jsonl, with no server required.

Wrapping a unit of work with with_run

with_run opens a run, runs your function, records the result (or the error), and closes the run — all on a verifiable chain. The callback receives a RunHandle you can use to record tool calls and custom events.

from proofledger import enable, with_run, verify_run

enable(local=True)  # local dev mode, no api key

def do_work(run):
    # Record a tool call — emits tool.called + tool.returned around the record.
    run.record_tool_call(
        tool_name="search_kb",
        input={"query": "refund policy"},
        output={"hits": 3},
    )
    return {"answer": "Refunds within 30 days."}

result = with_run({"agent_id": "support-agent", "model": "gpt-4.1"}, do_work)

# Verify the run's hash chain.
report = verify_run(...)  # pass the run id; see examples/basic.py
print(report["valid"])    # True

See examples/basic.py for a complete, runnable example:

python examples/basic.py

Hashing primitives

The same primitives the dashboard uses are re-exported:

from proofledger import (
    create_payload_hash,
    create_event_hash,
    verify_event_chain,
    GENESIS_HASH,
)
  • Canonical JSON: object keys are sorted recursively and serialized with no whitespace and literal Unicode, matching JS JSON.stringify with sorted keys.
  • GENESIS_HASH is 64 zeros — the previousHash of the first event.
  • create_event_hash commits to the event id, type, timestamp, payload hash, and the previous event's hash, chaining every event to the one before it.

Because the canonicalization and digests match the TypeScript SDK exactly, a chain captured in Python verifies identically in the ProofLedger dashboard.

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

proofledger-0.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

proofledger-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for proofledger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2609cfe4ce55d6aede9b5fce25830eee3a0d8c7d08e4fd9d25dd7a015567f7b9
MD5 b603d2a8021f7322f172ced3d0425f6c
BLAKE2b-256 53c39a131919a8c603935d24d45fc537622d72ab14211f33c3171c9f5b7db1f6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for proofledger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31eeb94b48fc560655a46ffc22f224d7aa4ef39da1b26d06d2052519160a509c
MD5 a0e686c10e99b5a30e39f39f34463d65
BLAKE2b-256 ed56727b27bd21e67b4f534883c8285b0c9848dcc3e80af252d6cd9055e19c16

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