HTTP/1.1 402 PAYMENT REQUIRED agent402.base.eth · BASE · SOLANA · POLYGON · ARBITRUM · MONAD · CELO · AVALANCHE · SEI · OPTIMISM · STELLAR · ALGORAND · ROBINHOOD · USDC · USDG
Agent402 / tools / route-execute-pro

Route and execute (pro tier)

FREE with proof-of-work · or $3.3 in USDC · POST /api/route/execute-pro

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call - flat $3.3 covering any tool listed at $3 or less, from THIS host's catalog or any external x402 seller in the open index (paid over x402 on your behalf, result relayed). One payment, one request, result + receipt. /api/route quotes which tier a task needs; pricier tools return a self-correcting 409 with their direct route.

Input

FieldTypeDescription
taskstringPlain-language task, e.g. "sha256 hash of a string" - resolved via the same ranker as /api/find. Provide task OR slug.
slugstringExact tool slug to execute (skips ranking). Provide task OR slug.
paramsobjectInput for the resolved tool, matching its inputSchema (default {})
includestringWhere to route: default runs a tool from THIS host's catalog; "external" routes to the best-matching x402 seller in the OPEN index and pays it on your behalf (result relayed, marked untrustedContent). Requires task (not slug).
maxUsdnumberRefuse tools listed above this underlying price (default and ceiling: $3)

Example output

{
  "receipt": {
    "slug": "hash",
    "route": "POST /api/hash",
    "underlyingPriceUsd": 0.001,
    "paidUsd": 3.3,
    "routingFeeUsd": 0.009,
    "seller": "internal",
    "resolvedBy": "slug",
    "ts": "2026-07-10T00:00:00.000Z",
    "callRef": "sha256:…  (recomputable: sha256 of {\"nonce\":<payment authorization nonce>,\"slug\":…,\"ts\":…} - null on nonce-less calls)"
  },
  "result": {
    "algo": "sha256",
    "hex": "…",
    "base64": "…"
  }
}

Try it - see the 402 challenge (free)

curl -i -X POST https://agent402.tools/api/route/execute-pro \
  -H "Content-Type: application/json" \
  -d '{"slug":"hash","params":{"text":"agent402","algo":"sha256"}}'

The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:

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();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/route/execute-pro", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "slug": "hash",
    "params": {
      "text": "agent402",
      "algo": "sha256"
    }
  }),
});

No wallet? Pay with compute

This is a pure-CPU tool, so an agent without a wallet can pay with proof-of-work instead of USDC: fetch a challenge, solve the sha256 puzzle (16 leading zero bits - a fraction of a second of CPU, no money, no AI tokens), and resend with the X-Pow-Solution header.

import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=route-execute-pro")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/route/execute-pro", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "Content-Type": "application/json" }, body: JSON.stringify({"slug":"hash","params":{"text":"agent402","algo":"sha256"}}) });

Related tools

Route and execute

$0.01 · POST /api/route/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 (plus tier)

$0.05 · POST /api/route/execute-plus

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)

$0.55 · POST /api/route/execute-max

Describe a task (or name a slug) and the Smart Order Router resolves the best-matching tool and RUNS it in the same call…