Your first Agent402 call in 60 seconds
Pick your stack, copy the snippet, and you're live.
Add to Claude Code
One command and you're done - 500+ tools available instantly.
Installclaude mcp add agent402 -s user -- npx -y agent402-mcp@latest
# "extract the tables from this PDF"
# "geocode these 50 addresses"
# "fetch Apple's latest 10-K"
Or paste the hosted connector URL (zero install):
https://agent402.tools/mcp
- Browse all tools to see what's available
- Try the playground for interactive testing
- Read the MCP docs for advanced config
Call any tool with curl
Standard HTTP - send JSON, get JSON back. No SDK required.
Web search, then a cited answer: see each 402 quote (free)curl -i "https://agent402.tools/api/search?q=x402+payment+protocol+adoption&count=5"
curl -i "https://agent402.tools/api/answer?q=what+is+the+x402+payment+protocol"
Each 402 carries the price and every way to pay it. A wallet client signs the payment and retries the same request: the Pay with USDC tab shows the same two calls paid from a wallet.
No wallet yet? The pure-CPU tools (hash, uuid, base64, markdown, JSON and more) run free with proof-of-work and no wallet:
Pay with proof-of-work (free, no wallet)# Grab a challenge: { "challenge", "difficulty", "token", ... }
curl -s "https://agent402.tools/api/pow/challenge?slug=hash"
# Find an integer nonce so sha256("<challenge>:<nonce>") has at least
# <difficulty> leading zero bits, then send the TOKEN (not the challenge):
curl -X POST https://agent402.tools/api/hash \
-H "Content-Type: application/json" \
-H "X-Pow-Solution: <token>:<nonce>" \
-d '{"text":"hello world","algo":"sha256"}'
- Use /api/find?q=<task> to discover tools by keyword
- Check /api/pricing for the full price list
- Add an
Idempotency-Keyheader for safe retries
Use the JavaScript SDK
Install agent402-client: it pays each call from your wallet, and pays the pure-CPU tools with proof-of-work.
Installnpm install agent402-client @x402/fetch @x402/core @x402/evm viem
import { Agent402 } from "agent402-client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const payClient = new x402Client();
registerExactEvmScheme(payClient, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, payClient);
const a = new Agent402({ fetch: payFetch }); // pays each call from the wallet
const found = await a.call("search", { q: "x402 payment protocol adoption", count: 5 });
const answer = await a.call("answer", { q: "what is the x402 payment protocol?" });
console.log(found.results, answer.answer, answer.citations);
No wallet yet? The pure-CPU tools (hash, uuid, base64, markdown, JSON and more) run free with proof-of-work and no wallet:
const free = new Agent402(); // no fetch: proof-of-work
const result = await free.call("hash", { text: "hello world", algo: "sha256" });
console.log(result);
- Use
a.find("geocode")to search tools programmatically - Set
maxPerCallUsdanddailyLimitUsdonnew Agent402()to cap what the wallet spends - Enable idempotent retries for production use
Use Agent402 as your model endpoint
Chat, the Anthropic Messages wire and embeddings, paid per request. The metered tier quotes each call from its own body.
Run the local wallet proxy (pays each call from your wallet over x402)npm i @x402/fetch @x402/evm viem
export AGENT402_WALLET_KEY=0x... # an EVM key holding USDC on Base
export AGENT402_MAX_PER_CALL_USD=2 # per-call ceiling checked before signing
npx agent402-openclaw proxy # serves http://127.0.0.1:8412/v1
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8412/v1", api_key="unused")
r = client.chat.completions.create(model="auto", messages=[{"role": "user", "content": "hi"}])
Every model id and its price: GET https://agent402.tools/v1/models. The proxy also answers the Anthropic wire: for Claude Code, set ANTHROPIC_BASE_URL=http://127.0.0.1:8412. Every host's settings: the agent-hosts guide.
Plug into any LLM framework
Drop-in tool definitions for OpenAI, Anthropic, and Vercel AI SDK.
Installnpm install agent402-openai-tools
# also: agent402-anthropic-tools, agent402-ai-sdk
import { agent402Tools } from "agent402-openai-tools";
// same shape: agent402-anthropic-tools
// payFetch: the wallet-paying fetch from the Pay with USDC tab
// web search, then a cited answer: both paid per call from the wallet
const { tools, execute } = await agent402Tools({ slugs: ["search", "answer"], freeOnly: false, fetch: payFetch });
// pass tools to your LLM call, e.g. "search the web for x402 adoption, then answer: what is x402?"
// for each tool_call it returns, run:
const result = await execute(call.function.name, JSON.parse(call.function.arguments));
// agent402-ai-sdk returns four meta tools instead, keyed by name:
// const tools = await agent402Tools({ fetch: payFetch }); await generateText({ model, tools, prompt });
No wallet yet? The pure-CPU tools (hash, uuid, base64, markdown, JSON and more) run free with proof-of-work and no wallet:
// free tier: every compute-payable tool, paid with proof-of-work
const { tools, execute } = await agent402Tools({ slugs: ["hash", "markdown-to-html"] });
- More wallet-only tools (extract, render, screenshot): add their slugs beside
freeOnly: false - Combine with the MCP connector for Claude-native integration
- See the playground for live examples
Pay directly with USDC on Base, Solana, Polygon, Arbitrum, Monad, Celo, Avalanche, Sei, Optimism, Stellar & Algorand - plus USDG on Robinhood Chain
Use the x402 protocol for on-chain payment - no API keys, no accounts.
Installnpm install @x402/fetch @x402/core @x402/evm viem
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?.(false); // @x402/core 2.23+ refuses anything over $1 or off the pegged-asset list by default; keep your own ceiling in code instead
registerExactEvmScheme(client, {
signer: privateKeyToAccount(process.env.AGENT_KEY)
});
const payFetch = wrapFetchWithPayment(fetch, client);
// web search, then a cited answer: each call quoted by its 402, then paid and retried
const q = (s) => encodeURIComponent(s);
const found = await (await payFetch("https://agent402.tools/api/search?q=" + q("x402 payment protocol adoption") + "&count=5")).json();
const answer = await (await payFetch("https://agent402.tools/api/answer?q=" + q("what is the x402 payment protocol?"))).json();
console.log(found.results, answer.answer, answer.citations);
- Check /api/pricing for per-tool USDC prices
- Add an
Idempotency-Keyheader so retries never double-charge - See /.well-known/x402 for the machine-readable payment manifest