Decide: tool plan for a task
POST /api/decideDescribe a job and get a call-ready plan: which tools, across this catalog and outside x402 sellers with a recently verified 402, solve it end to end, in what order, with fallbacks and input params that validate against each tool's schema. Send POST /api/decide with the required field task and pay quoted per request from $0.003 over x402 or MPP (there is no free tier). It returns a JSON object with decisionId, task, depth, plan, estimatedCostUsd and 6 more.
Priced by depth: quick $0.003 (one best tool), plan $0.01 (the default: steps, fallbacks, params from your task, cost and latency estimates), full $0.03 (the plan plus a compiled prompt). The fee comes back as a credit toward running the plan with POST /api/decide/execute. Free first: GET /api/find?q=<task> answers a multi-step task with a keyword plan sketch. The ranking formula has no first-party term; every tool carries firstParty. Uncovered needs are listed in gaps.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
task | string | yes | What the agent needs done (max 2000 chars) |
depth | string (one of: quick, plan, full) | no | quick | plan (default) | full |
constraints | object | no | maxBudgetUsd, maxLatencyMs, rails [x402|mpp], chains [CAIP-2 or namespace], excludeSellers [host], requireDeterministic |
Example request
curl -i -X POST https://agent402.tools/api/decide \
-H "Content-Type: application/json" \
-d '{"task":"Resolve the ENS name vitalik.eth and read its wallet balance on Base","depth":"plan"}'Without payment this returns HTTP 402 Payment Required with the exact price for decide; any x402 v2 or MPP client pays it and retries.
Example response
{
"decisionId": "dec_…",
"task": "Resolve the ENS name vitalik.eth and read its wallet balance on Base",
"depth": "plan",
"plan": [
{
"step": 1,
"purpose": "resolve the ENS name to an address",
"tool": {
"slug": "ens-resolve",
"firstParty": true,
"endpoint": "https://agent402.tools/api/ens-resolve",
"method": "GET",
"priceUsd": 0.001,
"exampleParams": {
"name": "vitalik.eth"
}
},
"fallbacks": [],
"dependsOn": []
},
{
"step": 2,
"purpose": "read that address's balance on Base",
"tool": {
"slug": "wallet-balance",
"firstParty": true,
"endpoint": "https://agent402.tools/api/wallet-balance",
"method": "POST",
"priceUsd": 0.002,
"exampleParams": {
"address": "{{step 1}}",
"network": "base"
}
},
"fallbacks": [],
"dependsOn": [
1
]
}
],
"estimatedCostUsd": 0.003,
"estimatedLatencyMs": 3000,
"confidence": 0.9,
"gaps": [],
"priceUsd": 0.01,
"executionCredit": {
"amountUsd": 0.01,
"token": "dc_…",
"redeemWith": "POST /api/decide/execute { decisionId, creditToken }"
},
"feedbackToken": "fb_…"
}| Field | Type | Always present | In the example |
|---|---|---|---|
decisionId | string | yes | dec_… |
task | string | yes | Resolve the ENS name vitalik.eth and read its wallet balance on Base |
depth | string | yes | plan |
plan | array of objects | yes | 2 items in the example |
estimatedCostUsd | number | yes | 0.003 |
estimatedLatencyMs | number | yes | 3000 |
confidence | number | yes | 0.9 |
gaps | array | yes | 0 items in the example |
priceUsd | number | yes | 0.01 |
executionCredit | object | yes | 3 fields: amountUsd, token, redeemWith |
feedbackToken | string | yes | fb_… |
From an MCP client
catalog.call {
"slug": "decide",
"params": {
"task": "Resolve the ENS name vitalik.eth and read its wallet balance on Base",
"depth": "plan"
}
}The hosted connector at https://agent402.tools/mcp needs a payment for decide; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.13.32.
Errors and behavior
taskis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool runs a model, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - Model-backed: the answer is generated by a model, so the same input can produce a different result.
- Priced per request: the 402 quotes this body, between $0.003 and $0.03.
- A
GETorHEADto /api/decide returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.03" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/decide", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"task": "Resolve the ENS name vitalik.eth and read its wallet balance on Base",
"depth": "plan"
}),
});Related tools
Decide: execute a plan
Run a decision's plan (decisionId from POST /api/decide), or a free plan sketch (steps), through Agent402: first-party.
Attest a settled call on Base
Write an on-chain attestation (Ethereum Attestation Service on Base) that binds a call you paid for to the bytes you.
Route and execute
Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call.
Route and execute (max tier)
Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call.
Route and execute (plus tier)
Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call.
Route and execute (pro tier)
Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call.