ArchitectureBeta

The request path

402, sign, verify, stream, bill. Inference starts optimistically while settlement runs beside it.

Owner
Protocol
Version
router-2026.07
Verified
2026-07-13

A funded request carries the query, price, and payment authorization in one HTTP exchange. Production agents use prepaid credits and a boundedx-credit-key; the x402 protocol remains the one-time funding rail and the advanced direct-payment fallback.

Beat by beat

  1. POST. The client sends an OpenAI-compatible chat request to /v1/chat/completions with x-credit-key.
  2. Auction. The router runs the second-score auction against the in-memory quote book in under 1 ms. No round trip to providers, no added latency: the competition already happened, in the standing quotes.
  3. Reserve. The router reserves the worst-case cost at the winner's cleared prices: estimated input tokens plus max_tokens of output. This is an upper bound, not the bill.
  4. Direct fallback. Without credits, the first request returns 402; the client signs a USDC authorization and retries with PAYMENT-SIGNATURE. Wallet libraries and the SDK do this automatically.
  5. Start and meter. The router dispatches to the winning provider immediately. Tokens stream back through the metering proxy while the credit reservation remains held.
  6. Bill actuals. At stream end the router bills the metered token counts at the cleared rates, never the reserved maximum. The unused remainder releases immediately, and the request gets a signed receipt.
one request, six beats

What optimistic start risks, and how it is bounded

Starting inference before settlement confirms means the router briefly fronts the cost of a request whose payment could still fail. That exposure is deliberately small and capped twice: per wallet (a hard limit on unsettled value any one payer can have in flight) and router-wide (a global cap across all wallets). A wallet whose settlement fails is demoted to settle-before-stream until it proves good again. The worst case is a bounded, priced risk, and in exchange the customer never waits on a chain.

warm pathReturning clients skip the 402 round trip entirely: every response carries a short-lived signed price attestation, so the next request can arrive with payment already attached against known pricing.
As a customerThe 402 number is the most you can pay, not what you will pay. You are charged metered actuals, the difference comes back automatically, and the receipt plus /v1/analytics shows exactly how the price was formed.
As a providerBy the time a request reaches you it is funded: signature and balance verified, cleared price locked. You serve tokens; the router carries the settlement risk inside its bad-debt caps, and your payout nets up at the epoch regardless of chain timing.