-
Notifications
You must be signed in to change notification settings - Fork 12
API Reference
All endpoints live at https://agent402.tools (hosted instance) or your self-hosted root. Discovery endpoints are free and unpaywalled. Tool endpoints require payment (x402 or proof-of-work) unless FREE_MODE=true.
These are always free. No wallet, no PoW, no auth.
Resolve a natural-language task description to the best matching tool(s). Lexical ranking against the full catalog.
curl 'https://agent402.tools/api/find?q=convert%20pdf%20to%20text&k=3'Returns an object, not a bare array:
{
"query": "convert pdf to text",
"count": 3,
"results": [
{ "slug": "pdf-to-markdown", "name": "…", "route": "…", "price": "$0.010",
"callExample": "…", "example": { }, "required": ["url"], "inputSchema": { },
"category": "web", "description": "…", "score": 42,
"computePayable": false, "docs": "https://agent402.tools/tools/pdf-to-markdown" }
],
"packs": []
}results holds the ranked tools; count is how many came back; packs holds any
matching Skill Pack for the same query, so a task-shaped question
can point at a whole workflow instead of one tool.
Cross-seller Smart Order Router. Finds the cheapest healthy tool for a task across Agent402 and every x402 seller crawled from the Coinbase CDP Bazaar.
curl -X POST https://agent402.tools/api/route \
-H 'Content-Type: application/json' \
-d '{"query":"screenshot webpage","top":3,"include":"external"}'Full catalog: every tool with its price, category, input schema, and example input.
curl https://agent402.tools/api/pricing| Endpoint | Returns |
|---|---|
GET /openapi.json |
OpenAPI 3.1.0 spec for all tool endpoints |
GET /llms.txt |
Agent-oriented plain-text catalog description |
GET /.well-known/x402 |
x402 service manifest (payment capabilities, networks, wallet) |
GET /api/reliability |
Uptime and health report |
GET /api/stats |
Aggregate call counts, revenue, cache statistics |
GET /api/leaderboard?top={n}&include={all|external}&sort={usd|calls} |
On-chain ranking of x402 sellers by Base USDC volume |
GET /health |
Liveness probe. The public body is only { "ok": true, "meta": { "toolCount": <n>, "build": "<short sha>" } }. Process uptime and the operating-mode flags are operator-only and appear on the authenticated response, not here |
Tools accept GET (query params) or POST (JSON body), depending on the tool. The catalog (/api/pricing, /openapi.json) specifies the method and schema for each.
Trust evidence for one x402 seller origin, so a buyer can vet a seller before routing money to it. Returns whether the origin is indexed, whether its manifest parses, how many tools it publishes, which chains it actually advertises, how many settled calls it has been observed receiving on-chain, and whether the Smart Order Router would spend buyer money there. The router's gate comes back field by field, so a refusal is explainable.
It never fetches the seller at call time: this is accumulated crawl and settlement evidence, not a liveness probe.
POST /api/sql-guard ($0.004) reviews one SQL statement an agent is about to run
and returns a verdict (pass / warn / block) with the risks named; on pass
it also returns an Ed25519 certificate binding that verdict to the SHA-256 of the
exact statement. POST /api/sql-cert-verify ($0.001) is the gate your database
layer calls before it obeys the agent, checking the signature, the version, the
expiry, and that the statement hash matches. See Tool Catalog for the full
behavior and the honest scope of the check.
Chat, embeddings, image generation, and text-to-speech are also served OpenAI-compatibly under /v1 - POST /v1/{nano,auto,pro,premium}/chat/completions, POST /v1/chat/completions, POST /v1/embeddings, POST /v1/images/generations, POST /v1/audio/speech, with GET /v1/models free. See LLM Gateway (OpenAI /v1) for tiers, the model-optional auto router, streaming, and caching. POST /api/route/execute runs the resolver's top pick in one paid call, and POST /api/my-usage returns the paying wallet's own purchase history.
curl 'https://agent402.tools/api/dns?name=example.com&type=A'curl -X POST https://agent402.tools/api/hash \
-H 'Content-Type: application/json' \
-d '{"text":"hello world"}'Successful responses return 200 with a JSON body. The shape varies by tool but is documented in each tool's inputSchema / example in the catalog.
- Call a paid tool without payment.
- Server responds
402with a JSON body containingx402Version,accepts(array of payment options: price, network, asset, pay-to address). - Sign a USDC
transferWithAuthorizationfrom your wallet. - Retry the same request with the payment header (as specified by the x402 protocol).
- The facilitator verifies and settles on-chain; the server returns the tool result.
# Step 1: see the quote
curl -i -X POST https://agent402.tools/api/hash \
-H 'Content-Type: application/json' \
-d '{"text":"hello"}'
# HTTP/2 402
# {"x402Version":2,"accepts":[{"price":"1000","network":"eip155:8453",...}]}See Paying with x402 for full code examples in JavaScript and with Stripe's purl.
-
GET /api/pow/challenge?slug={tool}-- receive{ challenge, difficulty, token, expiresAt }. - Find a
noncesuch thatsha256(challenge + ":" + nonce)has at leastdifficultyleading zero bits. - Retry the tool request with header
X-Pow-Solution: {token}:{nonce}.
# Get challenge
curl 'https://agent402.tools/api/pow/challenge?slug=hash'
# After solving, call the tool
curl -X POST https://agent402.tools/api/hash \
-H 'Content-Type: application/json' \
-H 'X-Pow-Solution: TOKEN:NONCE' \
-d '{"text":"hello"}'Challenges are single-use, short-lived, and scoped to exactly one slug. See Paying with Compute for a reference solver.
Send an Idempotency-Key header to enable idempotent requests. If the same key is seen again for the same method, path, and payment credential, the server replays the cached result without re-charging.
curl -X POST https://agent402.tools/api/hash \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: my-unique-key-123' \
-H 'X-Pow-Solution: TOKEN:NONCE' \
-d '{"text":"hello"}'Cache key formula: sha256(METHOD + path + Idempotency-Key + gate-credential). Without the header, every request is treated as unique.
The cache is settlement-aware: a response body is captured when the handler produces it but is only committed to the cache once the final status is 200, i.e. after settlement succeeded. A 200 whose settlement then failed (and therefore became a 402) is never cached and never replayed. Streamed responses are never replayable.
| Surface | Limit | Notes |
|---|---|---|
| PoW tier | Natural (CPU cost per challenge) | 200+ pure-CPU tools only; difficulty 16 = ~65k hashes |
MCP connector (/mcp) |
20/min, 120/hr per IP | Pure-CPU set only; override with AGENT402_MCP_MAX_PER_MIN/HOUR
|
All errors return a JSON body with an error string field.
{ "error": "description of what went wrong" }| Code | Meaning |
|---|---|
400 |
Bad request -- missing or invalid input parameters |
402 |
Payment required -- x402 quote included in body |
404 |
Tool not found |
409 |
Conflict -- the request cannot be served as asked, and the body says how to fix it. Two cases: an execution tier too small for the resolved tool (retry on the rung named in the error, or call the tool directly), and external routing on a chain with no spending wallet (the error names the chains that are supported) |
413 |
Payload too large -- for the memory tools, the namespace quota is full: either the per-namespace key count (MEMORY_MAX_NS_KEYS, default 10,000) or the total-value byte budget (MEMORY_MAX_NS_BYTES, default 32 MB). Delete keys or shrink values |
422 |
Unprocessable -- the payment itself is structurally unusable. On Algorand, a signed transaction whose validity window cannot outlive the tool is rejected before the handler runs, so a dead transaction can never leave you refunded while our upstream spend is burned. Re-sign with a longer validity window |
429 |
Rate limited -- retry after the Retry-After header value |
500 |
Internal server error |
502 |
Bad gateway -- upstream dependency failed |
503 |
Service unavailable -- upstream temporarily unreachable, or an optional integration is unconfigured on this instance |
504 |
Gateway timeout -- upstream timed out |
Handlers throw errors with .statusCode set; the server maps these to the appropriate HTTP response.
Every code in the 4xx/5xx rows above cancels settlement, so none of them charge you. Only a 200 that then settles successfully is billed. See Architecture for the ordering.
- Tool Catalog -- what the 500+ tools are and how agents discover them
- Paying with x402 -- USDC payment flow with code examples
- Paying with Compute -- proof-of-work protocol and reference solver
-
MCP Connector -- hosted connector and the
agent402-mcpnpm server - Self-Hosting -- deploying on your own infrastructure
agent402.tools · synced from wiki/ in the main repo — edit there, not here.
Using it (for agents / buyers)
- Getting Started
- Paying with x402
- Robinhood Chain (USDG)
- Paying with Compute
- MCP Connector
- Adapters
- AWS Bedrock AgentCore
- Tool Catalog
- Skill Packs
- x402 Index and Router
- x402 Leaderboard
- LLM Gateway (OpenAI /v1)
- LLM Proxy Gateway
- Image Generation Gateway
- Code Execution Sandbox
- Text-to-Speech
- Speech-to-Text
- Text Embeddings
- Payments and x402
- Memory and Coordination
Tollbooth (for site owners)
- Pay-per-crawl — what it is, install, modes
- Pay-per-crawl Walkthrough — 5-min hands-on
- Tollbooth for Agencies — many-site playbook
- Try Tollbooth Cloud (managed)
Website & Developer
- Quickstart — first call in 60 seconds
- Playground — try tools in your browser
- SDK REPL — live code editor
- API Explorer — browse OpenAPI
- Adapter Docs — per-framework guides
- Workflows — chaining patterns
- Blog · Changelog
Under the hood