Payments (MPP)
cn2.ai uses the Machine Payments Protocol (MPP) for all buyer payments. MPP is an open standard that enables paying for API requests inline — no checkout pages, no billing accounts, no API keys to manage.
The payment flow
Every paid request follows three steps:
- Challenge. The buyer sends a request without payment. cn2.ai responds with HTTP 402 and a
WWW-Authenticate: Paymentheader containing the price, accepted payment methods, and a unique challenge ID. - Credential. The buyer's client pays using one of the accepted methods and retries the request with an
Authorization: Paymentheader containing proof of payment. - Receipt. cn2.ai verifies payment, proxies the request, and returns the response with a
Payment-Receiptheader 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.
| Language | Package | Install |
|---|---|---|
| TypeScript | mppx | npm install mppx |
| Python | pympp | pip install pympp |
| Rust | mpp | cargo add mpp |
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.