Pay per request
Call the API without a key. The server answers 402 with a price; your wallet signs a permit, and the request goes through.
The exchange
1 Ask
POST the request with no key. The server answers 402 Payment Required with a PAYMENT-REQUIRED header: base64 JSON naming the price, the token and who to pay.
2 Sign
The wallet signs an EIP-2612 permit letting X402Activator take exactly that amount of INFERENCE. Signing costs no gas.
3 Retry
Send the same request with the permit in PAYMENT-SIGNATURE. The server submits it to X402Activator, which activates the amount as credit for your own account.
4 Answer
The answer comes back with PAYMENT-RESPONSE naming the activation transaction on Sepolia.
Try with your wallet
Sign in to sign a permit with your wallet. It needs at least 0.1 INFERENCE on Sepolia, and no ETH.
Sign inFrom code
# 1. Ask without paying: 402 with the price in PAYMENT-REQUIRED
curl -i https://deference.dea.web.id/api/proposal/x402/chat \
-H "Content-Type: application/json" \
-d '{"prompt":"Write one sentence about Sepolia."}'
# 2. Sign the permit with your wallet, then retry with it
curl https://deference.dea.web.id/api/proposal/x402/chat \
-H "Content-Type: application/json" \
-H "PAYMENT-SIGNATURE: $(echo -n '{"owner":"0x…","amount":"100000","deadline":"…","v":27,"r":"0x…","s":"0x…"}' | base64 -w0)" \
-d '{"prompt":"Write one sentence about Sepolia."}'