usertrust

usertrust

Budget holds, audit trails, and spend limits for every LLM call.

usertrust wraps any LLM client (Anthropic, OpenAI, Google) with a JS Proxy so every governed AI call becomes an auditable, double-entry financial transaction, recorded on a tamper-evident audit chain.

Keep your keys. Keep your billing. Add trust in one line.

import Anthropic from "@anthropic-ai/sdk";
import { trust } from "usertrust";

const client = await trust(new Anthropic(), { dryRun: true, budget: 50_000 }); // dryRun skips TigerBeetle for a first try
// ... governed calls ...
await client.destroy(); // required — flushes the audit chain and releases its lock

Core guarantees

  • Two-phase spend lifecycle — every governed LLM call follows PENDING hold → LLM call → POST (success) or VOID (failure). The same pattern banks use for credit card holds.
  • SHA-256 hash-chained audit trail — append-only JSONL. Each event chains from the previous via deterministic canonicalization. Tamper-evident by construction.
  • Merkle proofs (RFC 6962) — domain-separated hashing with inclusion and consistency proofs for public verifiability.
  • Real double-entry accounting — TigerBeetle ledger with nine transfer codes. Not a counter.
  • Duck-typed client detection — works with any Anthropic, OpenAI, or Google SDK. No direct imports.

Explore the docs

Stack

LayerTechnology
RuntimeNode 22, ESM
LanguageTypeScript 5.9 (strict, noUncheckedIndexedAccess)
LedgerTigerBeetle
ValidationZod
PolicyYAML + minimatch
TestVitest

License

Apache 2.0 — View on GitHub