Tools / Crypto
x402 spend preflight
Give it the x402 endpoints your agent is about to call and your spending rules (per-request cap, total budget, allowed networks). It probes every endpoint without paying, in parallel, and returns which ones are safe to pay, the real price in USD, network and pay-to address of each, the total cost, and a plain reason for every endpoint it blocks (over the cap, over budget, testnet only, not a valid x402 endpoint, non-USD price). Use it as a guardrail step in any agent that spends money.
- Price per call
- $0.005 USDC
- Endpoint
- POST https://x402-tools.com/v1/x402-preflight
- Also accepts
- GET with query parameters
- Payment
- x402, exact scheme, USDC on Base
- Returns
- application/json
Parameters
| Name | Type | Description |
|---|---|---|
| urls required | array | 1 to 10 x402 endpoint URLs, or objects { url, method } to probe with POST. |
| max_price_usd | number | Per-request cap in USD. Endpoints that cost more are blocked. |
| budget_usd | number | Total budget in USD for this batch. Endpoints are approved in order until it runs out. |
| networks | array | Allowed networks, e.g. ["base"] or ["eip155:8453"]. Default: any mainnet. |
Call it from an agent
import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const paidFetch = wrapFetchWithPayment(fetch, account);
const res = await paidFetch("https://x402-tools.com/v1/x402-preflight", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
"urls": [
"https://x402-tools.com/v1/markdown",
"https://x402-tools.com/v1/image"
],
"max_price_usd": 0.01,
"budget_usd": 0.02,
"networks": [
"base"
]
}),
});
// costs $0.005 in USDC on Base
Without a payment the endpoint answers 402 with the price, so you can inspect it first:
curl -i -X POST "https://x402-tools.com/v1/x402-preflight" -H "content-type: application/json" -d '{"urls":["https://x402-tools.com/v1/markdown","https://x402-tools.com/v1/image"],"max_price_usd":0.01,"budget_usd":0.02,"networks":["base"]}'
Example response
{
"checked": 2,
"approved": 1,
"blocked": 1,
"total_cost_usd": 0.003,
"rules": {
"max_price_usd": 0.01,
"budget_usd": 0.02,
"networks": [
"base"
]
},
"endpoints": [
{
"url": "https://x402-tools.com/v1/markdown",
"ok_to_pay": true,
"reasons": [],
"price_usd": 0.003,
"network": "eip155:8453",
"network_name": "Base",
"pay_to": "0x8e27…AB92",
"scheme": "exact",
"grade": "A"
},
{
"url": "https://x402-tools.com/v1/image",
"ok_to_pay": false,
"reasons": [
"Costs $0.02, above the per-request cap of $0.01."
],
"price_usd": 0.02,
"network": "eip155:8453",
"network_name": "Base",
"grade": "A"
}
]
}
If the tool fails or your input is invalid, the payment is not settled.
Other tools
Web page to markdown$0.003
Turn any URL (HTML, PDF, Office docs) into clean markdown an agent can read.
Website screenshot$0.01
A PNG screenshot of any web page, rendered in a real browser.
Summarize text or a URL$0.005
A faithful short, medium or long summary of any text or web page.
Extract structured data$0.01
Pull JSON fields out of any text or web page, matching your schema.
Translate text$0.003
Translate text into any language, keeping formatting and tone.
Generate an image$0.02
Text-to-image with FLUX.1 schnell, returned in seconds.