Inference an agent can buy by itself.
No sign-up, no API key, no card. An agent with a Monad wallet and some USDC pays with x402, the HTTP 402 payment standard. Settlement is gasless for the agent: Monad's x402 facilitator submits the USDC transfer.
Mode 1 · Pay per call
Call any paid endpoint with no credentials. You get 402 with a PAYMENT-REQUIRED header naming that request's worst-case price in USDC on Monad. Sign the payment, retry with PAYMENT-SIGNATURE, receive the answer plus a PAYMENT-RESPONSE receipt.
Anything the call did not use stays in your wallet's credit balance and is spent first next time (sign in, below). Per-call payments are capped at $1 by default; prepay for bigger jobs.
Mode 2 · Prepay, then sign in
POST /v1/x402/top-up?usd=10 answers 402 for $10; pay it once. Then send a SIGN-IN-WITH-X header on each call: a fresh SIWE message signed by the same wallet. One signature per request, no payment round-trip, lowest latency.
Top-ups go from $1 to $1,000 per payment. Your balance is on chain in CandorCredits; humans can top it up from the Account page too.
A paying agent in 30 lines.
Uses the official x402 libraries. Download the full script (both modes).
npm i @x402/core@2.29.0 @x402/evm@2.29.0 viem
import { x402Client, x402HTTPClient } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const URL = "https://ai.dagentx.com/v1/chat/completions";
const agent = privateKeyToAccount(process.env.AGENT_KEY); // holds USDC on Monad
const x402 = new x402Client();
x402.setSpendControls({ maxAmountPerPayment: "$1" }); // never pay more than this per call
registerExactEvmScheme(x402, { signer: agent, networks: ["eip155:143"] });
const http = new x402HTTPClient(x402);
const body = JSON.stringify({ model: "venice/zai-org-glm-5", max_tokens: 400,
messages: [{ role: "user", content: "Summarize x402 in one line" }] });
const init = { method: "POST", headers: { "content-type": "application/json" }, body };
let res = await fetch(URL, init);
if (res.status === 402) {
const required = http.getPaymentRequiredResponse((h) => res.headers.get(h), await res.json());
const payment = await http.createPaymentPayload(required);
res = await fetch(URL, { ...init, headers: { ...init.headers, ...http.encodePaymentSignatureHeader(payment) } });
}
console.log((await res.json()).choices[0].message.content);import { createSiweMessage } from "viem/siwe";
import { randomBytes } from "node:crypto";
// 1. once: POST https://ai.dagentx.com/v1/x402/top-up?usd=10 and pay the 402 (same as per call)
// 2. every call: a fresh, single-use sign-in for that exact URL
async function signIn(agent, url) {
const now = new Date();
const message = createSiweMessage({
domain: "ai.dagentx.com", uri: url, chainId: 143, version: "1",
address: agent.address, statement: "Sign in to WRAITH Nexus",
nonce: randomBytes(12).toString("hex"),
issuedAt: now, expirationTime: new Date(now.getTime() + 5 * 60_000),
});
const signature = await agent.signMessage({ message });
return Buffer.from(JSON.stringify({ address: agent.address, message, signature, chainId: 143 })).toString("base64");
}
const url = "https://ai.dagentx.com/v1/chat/completions";
const res = await fetch(url, { method: "POST", body,
headers: { "content-type": "application/json", "SIGN-IN-WITH-X": await signIn(agent, url) } });
// balance and usage: GET /relay/account with a sign-in for that URL→ POST /v1/chat/completions (no Authorization header)
← 402 PAYMENT-REQUIRED: base64(JSON)
{ "x402Version": 2,
"resource": { "url": "https://ai.dagentx.com/v1/chat/completions", … },
"accepts": [{ "scheme": "exact", "network": "eip155:143",
"asset": "0x754704Bc059F8C67012fEd69BC8A327a5aafb603", // USDC
"amount": "8400", // $0.0084, 6 decimals
"payTo": "<relay wallet>", "maxTimeoutSeconds": 300,
"extra": { "name": "USDC", "version": "2" } }] }
Sign an EIP-3009 transferWithAuthorization for exactly those terms.
→ POST /v1/chat/completions
PAYMENT-SIGNATURE: base64({ x402Version: 2, accepted: <the offer>, payload: { signature, authorization } })
← 200 PAYMENT-RESPONSE: base64({ success, transaction, network, payer })
SIGN-IN-WITH-X = base64({ address, message, signature, chainId: 143 })
message: EIP-4361 (SIWE), domain ai.dagentx.com, uri = the exact URL called,
chain id 143, issued ≤ 5 minutes ago, nonce used once.What agents should know
Price = worst case
The 402 amount is the most the call can cost: listed price for your input size and max_tokens, fee included. Set max_tokens to keep it small; unused value stays as your credit.
Payable endpoints
/v1/chat/completions, /v1/messages, /v1/embeddings, /v1/images/generations, /v1/audio/speech, /v1/audio/transcriptions.
Keys still work
An agent can also use a normal crk_ API key registered by its wallet. All three methods share one on-chain balance.
Gas
None for paying: the facilitator submits the USDC transfer. Your wallet only needs USDC.
Proof of what you bought
Every call is a signed record anchored on Monad. GET /relay/proof/:seq returns the Merkle proof for any of your calls.
Skill file
Give your agent the WRAITH Nexus skill and it knows all of this.