Skip to main content

Primordia economic metering for LangChain - track AI costs with machine-readable receipts

Project description

langchain-primordia

Economic settlement infrastructure for LangChain agents.

What is this?

Not just cost tracking. Clearing-grade settlement for AI agents.

MSR (local receipts)  →  IAN (kernel-signed netting)  →  MBS/ALR (audit-grade)
     FREE                      5 bps                        $25K+

Installation

pip install langchain-primordia

Quick Start (Shadow Mode - FREE)

from langchain_openai import ChatOpenAI
from langchain_primordia import PrimordiaCallbackHandler

handler = PrimordiaCallbackHandler(agent_id="agent-alpha")
llm = ChatOpenAI(callbacks=[handler])

response = llm.invoke("Hello")

# Local receipts accumulated
print(f"Receipts: {len(handler.get_receipts())}")
print(f"Total: ${handler.get_total_usd():.4f}")

Settlement (PAID - 5 bps)

When you need proof of settlement between agents:

handler = PrimordiaCallbackHandler(
    agent_id="agent-alpha",
    submit=True
)

# ... run your agent ...

# Net receipts into kernel-signed IAN
result = handler.net_receipts()

if "signed_ian" in result:
    # This is clearing-grade proof
    # Agent B can verify this signature
    print("IAN signed by Primordia kernel")
else:
    # 402 - need to purchase credit
    print(result["purchase_url"])

Audit-Grade Reports (Enterprise)

# Requires pack_team ($25K) minimum
mbs = handler.get_balance_sheet()

if "error" in mbs:
    # 402 - PACK_TEAM REQUIRED
    print("Purchase pack_team for audit-grade MBS")
else:
    # Kernel-signed Machine Balance Sheet
    print(mbs)

The Rail

Stage What Cost
MSR Local receipt per LLM call FREE
Index Submit receipts to kernel FREE
IAN Kernel-signed netting 5 bps
MBS Machine Balance Sheet $100 (pack_team min)
ALR Agent Liability Report $100 (pack_team min)
Default Resolution $25,000

Why Kernel Signature?

Agent A: "I paid Agent B $100"
Agent B: "Prove it"
Agent A: shows IAN with Primordia kernel signature
Agent B: verifies signature → TRUST

No kernel signature = no clearing-grade proof.

Links

License

MIT

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

langchain_primordia-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_primordia-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_primordia-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_primordia-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for langchain_primordia-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4e87ac7c8f3fc26a3f453c56ec15b35d4569cf4837322f908548bcd06989ce3
MD5 41f0abbeaa69be36fe711f0a34b8a70c
BLAKE2b-256 48bdece88dc49a4c12c7d2d970e30d3760b62f688582212ed9dc4d8d59b06bf8

See more details on using hashes here.

File details

Details for the file langchain_primordia-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_primordia-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e03414aa5e42b3c63668d1826851925dd07fe0ddd32ca97e543760a33b2e5478
MD5 a5d7f719ba6a7fe8ff2f4b7befb16d73
BLAKE2b-256 b9bff2684219a347fc1e352f93f53cacccccd301ca26faf82796761a60d19d59

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