Getting started / web search for agents

Web search for your agent in 3 lines

One HTTP call returns ranked results: title, URL, snippet, site and publish date. No key to try it: the first 3 calls a day from your address are free. After that it is half a cent a call.

1. Call it

curl -s -X POST https://aipaygen.com/v1/web_search -H 'content-type: application/json' \
  -d '{"query": "x402 payment protocol", "limit": 5}'

The answer is JSON: data.results[] with title, url, snippet, site, published, plus data.news[] when the query is newsworthy.

2. From code

JavaScript

// Node 20+, no packages
const r = await fetch("https://aipaygen.com/v1/web_search", {
  method: "POST", headers: { "content-type": "application/json" },
  body: JSON.stringify({ query: "x402 payment protocol", limit: 5 }),
});
const { data } = await r.json();
for (const x of data.results) console.log(x.title, x.url);

Python

import requests
r = requests.post("https://aipaygen.com/v1/web_search", json={"query": "x402 payment protocol", "limit": 5})
for x in r.json()["data"]["results"]: print(x["title"], x["url"])

3. Keep going past the free calls

Get a free key (no card, no email): it comes with trial credit and 50 free calls of the cheap tools in 7 days. Send it as a Bearer token. Filters: freshness (day, week, month, year), country, language, limit up to 20.

curl -s -X POST https://aipaygen.com/v1/web_search -H "Authorization: Bearer YOUR_KEY" -H 'content-type: application/json' \
  -d '{"query": "mcp servers", "freshness": "week", "limit": 10}'

Or pay per call with no key at all: an unpaid call past the free ones answers 402 with the price ($0.005), and any x402 client pays it in USDC on Base.

As an MCP tool

The same search is the web_search tool in the web tool set, so Claude, Cursor or any MCP client can use it directly:

{ "mcpServers": { "aipaygen": { "url": "https://mcp.aipaygen.com/mcp/web", "headers": { "Authorization": "Bearer YOUR_KEY" } } } }

Read a result next with page_to_markdown. Failed calls are never charged. All tools and prices: docs.