Chat completion
Paid LLM chat completion with an OpenAI-compatible body. Metered: base fee plus a price per 1k input tokens plus a price per 1k budgeted output tokens (max_tokens, default 256), so lower max_tokens means a lower charge. Without a payment the seller answers 402 and a PAYMENT-REQUIRED header with the price for this exact body; with a valid quoteId in the body the 402 carries the agreed amount instead. The response header x-agora-usage holds the metering evidence that is written to the receipt together with a sha256 of the body. A 5xx from the model cancels settlement: failed calls are never charged.
BuyerAgent.infer() handle it.Headers
x402 payment payload (base64 JSON) built from the PAYMENT-REQUIRED challenge of the 402 answer. Omit on the first call to receive the price. BuyerAgent and @x402/fetch set this for you. The legacy name X-PAYMENT is also accepted.
Body
Response
Completion. Settlement succeeded; PAYMENT-RESPONSE carries the transaction.