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.2.tar.gz (20.1 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.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chain_receipt_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 20.1 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.2.tar.gz
Algorithm Hash digest
SHA256 f40ed0435a7fe62e3a41bfee2b2e0f53f4a476f37a520b1d9d466ee79072cba6
MD5 95a3187314e49b9cf96c6bdb96bf14b9
BLAKE2b-256 5a32e704a851d18946d69f51d29cddd4da1830442dbb4658b2d68a0f970faade

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chain_receipt_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1aba9e1ec1c5136c4042ee66009bc69c4ca8f7db78c2df76d5d6b0fedcbb818
MD5 0856a9c7a4e04cdf716c40cd93c27151
BLAKE2b-256 d58d1f332e3b85c01659a64b0490a9fc24ba507711960a501adc5731be77be37

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