Payments

cn2.ai supports two payment protocols on every endpoint: MPP (Machine Payments Protocol — Tempo USDC, Stripe, Lightning) and x402 (USDC on Base via Coinbase). Both are open standards for paying for API requests inline — no checkout pages, no billing accounts, no API keys to manage. The 402 response advertises both protocols; clients use whichever they support.

The payment flow

Every paid request follows three steps:

  1. Challenge. The buyer sends a request without payment. cn2.ai responds with HTTP 402 and a WWW-Authenticate: Payment header containing the price, accepted payment methods, and a unique challenge ID.
  2. Credential. The buyer's client pays using one of the accepted methods and retries the request with an Authorization: Payment header containing proof of payment.
  3. Receipt. cn2.ai verifies payment, proxies the request, and returns the response with a Payment-Receipt header confirming the transaction.

Payment methods

Stripe (card)
Pay with Visa, Mastercard, or any Stripe-supported card. Best for users who prefer traditional payment. One-time charge per request.
Tempo (USDC stablecoin)
Pay with USDC on the Tempo blockchain. Supports two modes: charge (one-time per request) and session (open a payment channel for high-throughput, pay-as-you-go billing with near-zero per-request fees). Sessions are ideal for streaming responses or high-volume workloads.
Lightning (Bitcoin)
Pay with Bitcoin over the Lightning Network. Fast settlement, low fees. One-time charge per request.

Client libraries

MPP client libraries handle the challenge-credential-receipt flow automatically. You call fetch() and the library intercepts 402 responses, pays, and retries.

LanguagePackageInstall
TypeScriptmppxnpm install mppx
Pythonpympppip install pympp
Rustmppcargo add mpp

x402 (USDC on Base)

As an alternative to MPP, cn2.ai also accepts x402 payments — USDC on the Base L2 network, verified via the Coinbase facilitator.

To pay via x402, include the payment proof in the x-402-payment header. The 402 response includes X-Payment-PayTo with the recipient wallet address and X-Payment-Amount with the USDC amount.

x402 uses USDC exclusively on the Base network. Payments are verified and settled by the Coinbase facilitator at x402.org.

Security

  • All connections require TLS 1.2 or later
  • Each challenge has a unique ID that can only be used once (replay protection)
  • For POST requests, the challenge is bound to the request body via a cryptographic digest — the body cannot be modified after receiving the challenge
  • Challenges expire within 30 seconds
  • cn2.ai never performs side effects on unpaid requests

Learn more

MPP is an open standard submitted to the IETF. Full specification and protocol details are available at mpp.dev and paymentauth.org.