Payments
Payments
TnsAI agents talk to other agents. Sometimes the other agent charges. The PaymentBroker SPI is the framework's answer to "how does an agent settle a payment without you, the human, in the loop?" — same surface for free internal calls (NoOpPaymentBroker), real on-chain micropayments (X402PaymentBroker), or your own custom rail.
Pages
- x402 (HTTP 402 + EIP-3009) — Coinbase-led standard. Sub-cent USDC payments over Base. The first concrete adapter on the
PaymentBrokerSPI.
When to think about payments
You don't need a payment broker for free internal multi-agent traffic — the default NoOpPaymentBroker lets the framework's accountability machinery thread through untouched. Reach for a real broker when:
- Your agent calls third-party services that charge per request — premium MCP servers, paid embedding endpoints, paid weather/news feeds. With x402, the server returns HTTP 402 and your broker auto-settles the micropayment; the response comes back as if you'd called a free endpoint.
- Your agent offers a paid service to other agents outside your trust boundary. Quote the price, accept the signed authorisation, settle on-chain (or via Stripe, Lightning, etc. — once those adapters ship).
- You need an audit trail showing exactly how much each agent spent and on what. Every settlement emits an
AgentLiabilityRecordfor downstream compliance.
Architecture
Quote(payer, payee, service)
Settlement {Settled | Rejected | Expired | AlreadySettled}
│ ▲
▼ │
┌──────────────────────────────────────────────────────────────┐
│ PaymentBroker (SPI, tnsai-core) │
└──────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────┼──────────────────────────┐
▼ ▼ ▼
NoOpPaymentBroker X402PaymentBroker (future adapters)
- default - tnsai-payments - Stripe
- free internal traffic - x402 / EIP-3009 - Lightning
- quotes at $0.00 - Base mainnet + Sepolia
- Wallet SPI for signingThe broker is the layer between your agent's chat loop and whatever rail moves the money. The rest of this section walks you through wiring it up.
Related
- Security: Accountability —
AgentLiabilityRecordaudit trail every broker emits to. - Security: Cost Governance — pair
CostBudget(broad LLM spend) withAuthorityScope.spendCeilingUSD(per-broker mandate) for layered controls. - Reference: SPI —
PaymentBrokercontract.