x402 AI Inference API
Call DGrid inference with x402 payment requirements. The first request returns payment instructions; the second request includes a signed x-payment header and executes inference.Payment and Authentication
This endpoint uses the x402 payment protocol instead of an account balance workflow. Required request headers for the paid request:Request Body
Response Modes
stream = true (default)
Returns UIMessageStream SSE (text/event-stream) using AI SDK style UIMessageChunk events. Common event types include:
starttext-starttext-deltatext-endfinish
finish event includes messageMetadata such as:
totalTokensallowanceLeftcalculatedPriceWeirealPriceWei
stream = false
Returns a single JSON response in DGrid’s standard completion format with choices and usage.
Errors
Settlement Notes
- The endpoint settles based on actual usage.
- If actual cost exceeds the authorized upper bound, settlement is capped at that authorized limit.

