One API. Every AI. Pay per call.
curl -i -X POST https://agents.dexl.io/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"gemini-3.6-flash","messages":[{"role":"user","content":"Hello"}],"max_tokens":256}'
You get a 402 with the exact price. Sign the payment, resend, get the answer.
Live catalogue with current pricing.
Send a real request, see the real quote.
Liveness, network and payment address.
Whether the facilitator is reachable and our network is supported.
Machine-readable spec. Discovery at /.well-known/x402.json.
Full documentation in the repository.
You are quoted for the ceiling you ask for, not for what the model ends up writing.
Payments below roughly this will not settle, so quotes are floored there.
A bad body or an unknown model is refused before the payment step. The 402 body lists valid ids.
A rejected payment returns a specific code — expired, already used, insufficient — plus the facilitator's own words in x402_error.
120 requests a minute per IP. Every response carries X-RateLimit-Remaining.
npm install @dexl/agents viem
const dexl = new DexL({ wallet });
const { amountUsd } = await dexl.quote({ model, messages, maxTokens: 512 });
const res = await dexl.chat.completions.create({ model, messages, maxTokens: 512 });
quote() asks the price without paying. Errors arrive as a typed
DexLError with a stable code and a retryable flag.