---
title: Payments
description: Agent-to-agent settlement — wire your agents to pay (and get paid) for the work they do, through the same PaymentBroker SPI regardless of the underlying rail.
---

# Payments

TnsAI agents talk to other agents. Sometimes the other agent charges. The [`PaymentBroker`](../reference/spi.md) 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 (`PaymentBroker.noOp()`), real on-chain micropayments ([`X402PaymentBroker`](x402.md)), or your own custom rail.

## Pages

- [x402 (HTTP 402 + EIP-3009)](x402.md) — Coinbase-led standard. Sub-cent USDC payments over Base. The first concrete adapter on the `PaymentBroker` SPI.

## When to think about payments

You don't need a payment broker for free internal multi-agent traffic — the default is `PaymentBroker.noOp()` (the `NoOpPaymentBroker` singleton). Accountability machinery threads 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 [`AgentLiabilityRecord`](../security/accountability.md) for downstream compliance.

## Architecture

```
                                Quote(payer, payee, service)
                                Settlement {Settled | Rejected | Expired | AlreadySettled}
                                          │  ▲
                                          ▼  │
┌──────────────────────────────────────────────────────────────┐
│ PaymentBroker (SPI, tnsai-core)                              │
└──────────────────────────────────────────────────────────────┘
                                          │
        ┌─────────────────────────────────┼──────────────────────────┐
        ▼                                 ▼                          ▼
  PaymentBroker.noOp()           X402PaymentBroker            (future adapters)
  - default (core)               - tnsai-payments              - Stripe
  - free internal traffic        - x402 / EIP-3009             - Lightning
  - quotes at $0.00              - Base mainnet + Sepolia
                                 - Wallet SPI for signing
```

The 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](../security/accountability.md) — `AgentLiabilityRecord` audit trail every broker emits to.
- [Security: Cost Governance](../security/cost-governance.md) — pair `CostBudget` (broad LLM spend) with `AuthorityScope.spendCeilingUSD` (per-broker mandate) for layered controls.
- [Reference: SPI](../reference/spi.md) — `PaymentBroker` contract.
