跳到正文
DEV Community· x402serps·· 2 小時前AI 評分57

x402serps 如何透過 x402 為 AI 智能體接入網頁搜尋(無需 API key)

How to give your AI agent web search with x402 (no API key)

AI 導讀

AI 智能體可透過 x402 呼叫 x402serps 網頁搜尋端點,收到 HTTP 402 後以 USDC 付款並在 X-PAYMENT 標頭中重試,毋須 API key。

正文

x402serps

Every x402serps endpoint is a normal JSON POST. Send it without payment and you get HTTP 402 back with payment requirements (price, network, payTo). An x402 client signs a USDC payment, puts it in the X-PAYMENT header and retries. There are no API keys.

1. Look at the 402

curl -i -X POST https://x402serps.com/api/v1/search \
  -H "content-type: application/json" -d '{"q":"x402 protocol","num":5}'

The payment-required header lists both Base (eip155:8453) and Solana USDC options, each for 4000 units ($0.004).

2. Try it free

curl -X POST https://x402serps.com/api/v1/search -H "content-type: application/json" \
  -H "X-Trial: 1" -d '{"q":"x402"}'

You get 25 trial calls, rate-limited to 10 a minute.

3. Pay with x402 from Node

import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.AGENT_KEY); // a low-balance agent wallet
const pay = wrapFetchWithPayment(fetch, account);

const r = await pay("https://x402serps.com/api/v1/search", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ q: "best MCP servers 2026", num: 10, freshness: "week" }),
});
const { results } = await r.json();
console.log(results.map(x => `${x.position}. ${x.title} ${x.url}`).join("\n"));

Use a dedicated wallet with a small balance and a spending cap.

4. Or use it over MCP

Add the remote server https://x402serps.com/api/mcp (streamable HTTP; MCP Registry name com.x402serps/search). Tools include web_search, news_search, extract, places_search and deep_research.

5. No wallet?

Buy prepaid credits by card at /pricing and send Authorization: Bearer xs_....

Pricing (as of 3 Nov 2026)

Search is $0.004 per 10 results and extract is $0.003 per URL. For comparison, Exa lists search from $4 per 1k requests, and Tavily lists pay-as-you-go at $0.008 per credit, with basic search costing 1 credit. Check their pages for current rates.

Docs: https://x402serps.com/docs?utm_source=devto&utm_campaign=launch

來源:DEV Community · dev.to