Home · Platform · For developers
Platform · For developers

Wrap your AI client. Ship a receipt.

One import, no application rewrite. Every call becomes a signed receipt, in the language your stack already uses.

Quickstart

From install to a verified receipt in minutes.

TypeScript
Python
Go
Rust
Java
import OpenAI from "openai";
import { wrapOpenAI, generateKeyPair } from "@askledger/receipts-sdk";

// Wrap the client once, your application code is unchanged
const client = wrapOpenAI(new OpenAI({ apiKey }), {
  tenantId: "acme",
  keypair: generateKeyPair(),        // production: HSM-backed
  onReceipt: async (r) => store.append(r),
});

const res = await client.chat.completions.create({ model, messages });
console.log(res.x_ledger_receipt_id);  // cryptographic evidence id
from askledger_receipts import wrap_openai, generate_keypair
from openai import OpenAI

# Wrap the client once, your application code is unchanged
client = wrap_openai(OpenAI(api_key=api_key),
    tenant_id="acme",
    keypair=generate_keypair(),        # production: HSM-backed
    on_receipt=lambda r: store.append(r))

res = client.chat.completions.create(model=model, messages=messages)
print(res.x_ledger_receipt_id)  # cryptographic evidence id
import receipts "github.com/askledger/receipts-sdk/go-sdk"

// Wrap the client once, your application code is unchanged
client := receipts.WrapOpenAI(openaiClient, receipts.Config{
    TenantID: "acme",
    Keypair:  receipts.GenerateKeyPair(), // production: HSM-backed
    OnReceipt: func(r receipts.Receipt) { store.Append(r) },
})

res, _ := client.Chat.Completions.Create(ctx, req)
fmt.Println(res.LedgerReceiptID) // cryptographic evidence id
use askledger_receipts::{wrap_openai, generate_keypair, Config};

// Wrap the client once, your application code is unchanged
let client = wrap_openai(openai_client, Config {
    tenant_id: "acme".into(),
    keypair: generate_keypair(),        // production: HSM-backed
    on_receipt: |r| store.append(r),
});

let res = client.chat().completions().create(req).await?;
println!("{}", res.ledger_receipt_id); // cryptographic evidence id
import io.askledger.receipts.*;

// Wrap the client once, your application code is unchanged
var client = Receipts.wrapOpenAI(openAiClient, Config.builder()
    .tenantId("acme")
    .keypair(Receipts.generateKeyPair())   // production: HSM-backed
    .onReceipt(store::append)
    .build());

var res = client.chat().completions().create(req);
System.out.println(res.ledgerReceiptId()); // cryptographic evidence id
Build by layer

Five layers, one import. Adopt only what a system needs.

Every function below ships in the open TypeScript SDK today (v0.13) and is exported from its public API. Layers 1 to 4 are the technical proof engine; Layer 5 is the governance and enablement program that wraps them, delivered as a service engagement rather than new API surface. Each layer is independent, so start with a signed receipt and add the rest when a system calls for it.

L1

Pre-execution guardian

prevent the wrong action
import { signPreVerdict, reviewNofM, assertActionCleared }
  from "@askledger/receipts-sdk";

const action = { tenant_id: "acme", action_type: "wire.transfer",
  payload: { to: "GB...", amountUsd: 40000 }, actor: "agent-7" };

// an INDEPENDENT reviewer signs a verdict bound to THIS exact action
const verdict = signPreVerdict(action,
  { verdict: "approve", reviewer: "risk-engine" },
  { keypair, reviewedAt });

// high-risk: require 2 distinct approvers, any reject is a veto
const { cleared } = reviewNofM(action, [v1, v2], { publicKeys, threshold: 2 });

// gate: throws unless the verdict verifies AND binds to this action
assertActionCleared(verdict, action, { publicKeys });
execute(action);
L2

Cryptographic evidence

prove what happened
import { verifyReceipt, verifyChain } from "@askledger/receipts-sdk";

// verify a single receipt
const ok = verifyReceipt(receipt, { publicKeys }).valid;

// verify a whole per-tenant hash chain, end to end
const chain = verifyChain(receipts, { publicKeys });
chain.valid;               // every link signs and follows its predecessor
chain.completeFromGenesis; // nothing missing from the first receipt on
L3

Execution traceability

prove how the run happened
import { verifyWorkflow } from "@askledger/receipts-sdk";

// rebuild a multi-step agent run as a DAG and verify it
const wf = verifyWorkflow(receipts, { publicKeys });
wf.valid;   // every receipt verifies, graph is complete and acyclic
wf.order;   // deterministic topological order of the steps
L4

Rule-based assurance

prove why it was sound
import { assuranceLevel, checkRules } from "@askledger/receipts-sdk";

// grade a receipt on the published ladder: L0 to L3
const { level, name } = assuranceLevel(signed, { attestedKids });
//    { level: "L2", name: "Attested" }

// check a decision against the policy recorded on the receipt
const res = checkRules(policy, { credit_score: 690 });
res.status;        // "verified" | "failed"
res.failed_rules;  // which rules did not hold
L5

Enablement and compliance

govern and scale

Layer 5 is not new API surface. It packages what the SDK already produces, the cost engine's signed baselines, the Layer 4 rule packs, and the assurance ladder, into a governance and enablement program. Every number is measured against signed evidence rather than asserted, which makes it tamper-evident and attributable. That is not the same as making it true, and causation stays a business judgement. See the five-layer model.

See it run

Clone the repo and watch every layer verify.

Two runnable walkthroughs ship in the repo. Each prints a per-step pass/fail report and exits non-zero if anything fails to verify, so they double as smoke tests. No keys, no signup, no cloud.

# clone and run; everything reproduces locally
$ git clone https://github.com/askledger/receipts-sdk && cd receipts-sdk
$ npm install

$ npm run demo:layers     # guardian blocks a bad wire, then chained, traced, graded
$ npm run demo:savings    # sign a baseline, prove the saving, reject a forgery
The stack

Five reference implementations, one wire format.

Open-core, vendor-neutral, and wire-format conformant across five languages in one open monorepo, sharing the same conformance vectors. A receipt signed in one language verifies in any other.

TypeScript

@askledger/receipts-sdk · live on npm

Python

python-sdk/ · from source

Go

go-sdk/ · from source

Rust

rust-sdk/ · from source

Java

java-sdk/ · from source

Any provider

OpenAI, Anthropic, Gemini, Bedrock, Cohere, Mistral, and more, plus LangChain, Cursor, and gateways.

TypeScript is published on npm today; Python, Go, Rust, and Java ship from the same open repository, with package-registry releases rolling out.

Read the protocol and the spec.

Everything is open, the protocol, the architecture, the conformance vectors, and the code.