Search autocomplete
GET /api/search-suggestSearch autocomplete: query suggestions for a partial input as a flat JSON array. Send GET /api/search-suggest with the required field q and pay $0.001 per call over x402 or MPP (there is no free tier). It returns a JSON object with query, count and suggestions.
Useful for query expansion, did-you-mean refinement, and topic exploration. Returns up to 20 suggestions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
q | string | yes | Partial query (max 400 chars) Also accepted as query, search, term, keyword. |
count | number | no | Suggestions to return, 1-20 (default 5) |
Example request
curl -i "https://agent402.tools/api/search-suggest?q=agent4&count=5"
Without payment this returns HTTP 402 Payment Required with the exact price for search-suggest; any x402 v2 or MPP client pays it and retries.
Example response
{
"query": "agent4",
"count": 5,
"suggestions": [
"agent402",
"agent4 mexico",
"agent4 movie",
"agent4you",
"agent 47"
]
}
| Field | Type | Always present | In the example |
|---|---|---|---|
query | string | yes | agent4 |
count | number | yes | 5 |
suggestions | array of string | yes | 5 items in the example |
From an MCP client
catalog.call {
"slug": "search-suggest",
"params": {
"q": "agent4",
"count": 5
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for search-suggest; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
qis 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 is cancelled when the tool fails. 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 reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
POSTwith a JSON body to /api/search-suggest is served as this GET, with the body as the input. - 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?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/search-suggest?q=agent4&count=5");
Related tools
Web answer
GET /api/answerAI-generated answer to a natural-language question, grounded in live web search results with source citations. Returns c…
Exa grounded answer
POST /api/exa-answerAsk a question and get a written answer with the sources it was drawn from. Exa searches its index, reads the pages and …
Exa page contents
POST /api/exa-contentsRetrieve the readable text of up to 10 web pages by URL, with optional query-focused highlights. Exa serves from its cra…
Exa neural web search
POST /api/exa-searchNeural (embedding-based) web search over Exa's curated index, which finds pages by meaning rather than keyword overlap. …
Farcaster cast search
POST /api/fc-cast-searchSearch Farcaster casts by keyword (literal, semantic or hybrid match), newest first, optionally filtered to one author o…
Farcaster user search
POST /api/fc-user-searchSearch Farcaster users by name or username fragment. Returns up to 10 compact profiles: fid, username, display name, bio…