Skip to main content

Chain-Receipt SDK — emit, verify, replay, and chain Receipts (v1.0.0) from LangChain runnables, agent loops, or any Python callable.

Project description

chain-receipt-sdk

Emit, verify, replay, and chain Chain-Receipts (v1.0.0) from any Python LLM-agent loop. Drop-in callback for LangChain, plus a framework-agnostic ReceiptBuilder for raw API loops.

Verifiable record of every LLM call: emit a signed Receipt, replay it against any vendor, and check whether the chain holds.

pip install chain-receipt-sdk
chain-receipt verify sha256:<hash>
chain-receipt replay sha256:<hash> --n 10

60-second demo

from chain_receipt_sdk import ReceiptBuilder, ClientInfo, Interaction
from chain_receipt_core import compute_text_hash, compute_tool_calls_hash, generate_keypair

sk, pub = generate_keypair()
client = ClientInfo(
    name="my-agent",
    version="0.1.0",
    platform="python-3.12",
    emitter_pubkey=f"ed25519:{pub}",
)
b = ReceiptBuilder(client=client, private_key=sk, chain_seed=pub.encode())

inter = Interaction(
    vendor="anthropic",
    model="claude-sonnet-4-5",
    temperature=0.0,
    system_prompt_hash=compute_text_hash("you are helpful"),
    prompt_hash=compute_text_hash("hello"),
    response_hash=compute_text_hash("hi"),
    tool_calls_hash=compute_tool_calls_hash([]),
    n_tool_calls=0,
    latency_ms=120,
)
r = b.build(interaction=inter)
print(r.receipt_id, r.chain.sequence_number)

LangChain callback

from langchain_core.runnables import RunnableLambda
from chain_receipt_sdk.callback import ReceiptCallback

cb = ReceiptCallback(
    client_name="my-langchain-agent",
    vendor="anthropic",
    model="claude-sonnet-4-5",
)
chain = RunnableLambda(lambda x: f"echo: {x}")
chain.invoke("hello", config={"callbacks": [cb]})

receipts = cb.receipts
print(f"emitted {len(receipts)} Receipts")

CLI

chain-receipt status                       # local chain head + count
chain-receipt verify sha256:<hash>         # validate signature + chain link
chain-receipt replay sha256:<hash> --n 10  # re-run captured prompt N times
chain-receipt chain --since 2026-04-25     # list Receipts since timestamp
chain-receipt publish sha256:<hash>        # push to chain-determinism.org

Local chain storage

Receipts are written to ~/.chain-receipt/chain.jsonl (one JSON per line) when emitted via ReceiptCallback or ReceiptBuilder.build(persist=True). The chain_receipt_sdk.chain.LocalChain reader/writer is the public API for that file.

Replay determinism

chain_receipt_sdk.replay re-runs the captured prompt against the same vendor + model + temperature N times and reports final_answer_consistent, tool_seq_identical, tool_args_identical, and a Wilson 95% CI for the divergence rate. Integration test gate in tests/test_replay.py.

License

MIT — see LICENSE.

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

chain_receipt_sdk-0.1.3.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

chain_receipt_sdk-0.1.3-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file chain_receipt_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: chain_receipt_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.15

File hashes

Hashes for chain_receipt_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 569f0945b91c3aa597eed9289989a27ae48ebc3a54fe73c5a04483323a29aa9c
MD5 b576adda52808d4f14fcdef33767f456
BLAKE2b-256 56919e1f6838c4a384f874f8665287cbf95294c6aaed8bae76db8594960de7b9

See more details on using hashes here.

File details

Details for the file chain_receipt_sdk-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for chain_receipt_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b4a8aa0de4659ec2c4a7900101032a444a9f0dcdca226a16e73587ded2c52b5
MD5 37976655c5a43e723c0ca49304401061
BLAKE2b-256 c7b7f4f8c4b370b9a91a92d644340628c22d4d06c916fdd838049a0235165b96

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