Payments

Charge for API, AI, or content access: get paid before serving a request, price AI crawler traffic, and prove what was consumed.

Three separate things, easy to conflate

SBproxy ships three payment-adjacent features that answer different questions. Getting paid decides whether a request reaches your origin at all. Pricing AI crawler traffic is a policy that issues and redeems 402 challenges for automated readers. Metering proves how much was consumed after the fact, and settles nothing on its own. Each has its own reference page; this one says which to read first.

Getting paid: proxy.payments

Off unless configured, and Apache-2.0 like everything else. One rule sits above the rest: a request reaches the origin only after a durable, committed record says the payment settled. Verified is not settled. A timeout, an open circuit breaker, or a write with an unknown fate all stop the request short of the origin.

One settlement state machine covers four rails: x402, Payment HTTP Authentication (MPP), Stripe, and Lightning (Core Lightning or LND as alternative backends for the same rail, never both at once).

proxy:
  payments:
    rails:
      - type: x402
        network: base-sepolia
        pay_to: "0x..."
        price_usd: 0.001

Before you cluster this

A node that configures both proxy.payments and proxy.cluster refuses to start. Settlement runs on one node against one SQLite file today, and the mesh cannot hold that state. This is the most common way a payments rollout gets blocked in planning, so check it before you design around horizontal scaling.

Pricing AI crawler traffic: Pay Per Crawl

An AI crawler without a payment token gets a 402 challenge, pays out-of-band, and retries with a token that redeems once

A policy that decides which requests are payable and what they cost, specifically for AI crawler traffic. A crawler without a valid payment token gets a 402 with a JSON challenge, pays out-of-band, and retries with a token that redeems exactly once. This policy does not settle payments by itself: with proxy.payments configured, settlement takes over 402 issuance; without it, an in-memory or HTTP ledger redeems tokens on its own.

Proving what was consumed

Two ledgers, two different questions, neither one a payment:

  • Metering cuts a signed, hash-chained receipt for every request an attesting origin serves: who consumed, on which route, how many units, at what outcome. A buyer holding only your published key set can re-derive the whole chain and catch a tampered entry.
  • AI usage ledger does the same hash-chained, optionally Ed25519-signed treatment for completed LLM calls on an AI gateway origin.
  • Value ledger is a different kind of accounting: dollars saved by routing to a local or self-hosted model instead of a configured cloud reference price. This is savings reporting for an operator, not a buyer-facing receipt.

What is not shipped

L402 is design notes only. There is no macaroon primitive, no L402 issuer or verifier, and no invoice-provider seam in the codebase today. If you need Lightning payments now, the Lightning rail under proxy.payments is what actually ships.

Where to start

You areStart with
Monetizing an API or AI endpoint for the first timePayment settlement, then the clustering note before assuming horizontal scale
Charging for AI model accessThe same settlement path on an AI gateway origin, plus the usage ledger for a provable spend record
Billing on consumption instead of gating accessMetering: a signed receipt chain a buyer can verify independently, distinct from settlement