Life of a request
Six beats from POST to receipt: auction, credit reserve, stream, meter, capture, refund. Direct x402 is the advanced fallback.
Every funded inference happens inside one HTTP exchange. The recommended path uses prepaid credits; the direct x402 fallback adds a quote-and-sign exchange before the funded request.
1 · POST
You send an OpenAI-compatible chat request to the router with a spend-capable x-credit-key. The key is the agent's bounded spending credential; an x-api-key can be added separately for attribution.
2 · The auction
The router scores every live quote for your model class in memory: price, measured latency, and quality, weighted by your priority. This takes under a millisecond and adds no network round trip. The winner and the cleared price are fixed here, before any money moves. Details in Second-score clearing and Scoring.
3 · Reserve prepaid credits
The router reserves your worst-case cost from prepaid credits at the winner's cleared prices (your token budget times the cleared rates). This is an upper bound, not the bill, and no payment round trip is needed.
4 · Stream and meter
Inference starts immediately. The metering proxy counts tokens and measures the provider's real latency, which feeds future auction scores. The credit hold remains reserved until the stream finishes.
5 · Capture actuals
At stream end the router captures metered actuals from the reservation and releases the unused remainder. There is no chain confirmation on the ordinary request path.
6 · Receipt and refund
You are charged metered actuals, not the reserved maximum, and any remainder releases automatically. The signed receipt records token counts, cleared prices, and credit/payment references, and each hour's records are hashed and anchored on-chain. The full economic breakdown (the reconstructed auction, every rival's counterfactual price) is one call away. See Receipts & analytics.
- router/src/http/server.ts credit reserve or x402 → auction → stream → bill
- router/src/api/proxy.ts metering and latency measurement
- router/src/money/payments.ts the x402 flow and exposure caps