SERP API for AI Agents: Structured Search Results in JSON (No API Key)
A SERP API turns a search query into search results your code can use. For an AI agent, that's usually the first tool it reaches for: before it can answer a question about a new release, a price or a docs page, it has to find the right pages. This guide explains what a SERP API is, why an agent needs structured results (title, URL, snippet) instead of raw HTML, and how to call AgentSearch three ways: a free relay with no key, pay-per-call over x402 on Base, and ready-made packages for MCP, LangChain and n8n.
Short version: AgentSearch Web Search gives you 25 free searches per IP in total, then pay per call, with no account and no API key. Paid search is $0.003 per call in USDC on Base, which is among the lowest per-call prices for agent web search.
What is a SERP API?
SERP stands for search engine results page: the list of links, titles and snippets you see after you type a query. A SERP API returns that list to a program. You send a query; you get back the ranked results.
There are roughly two kinds:
- SERP scraping APIs fetch a search engine's results page and parse it for you. They often return everything on the page: ads, maps, shopping boxes, "people also ask" panels and position data. That's what SEO and rank-tracking tools want.
- Search APIs for agents return just the organic results, already cleaned up, in a small JSON shape a language model can read without wasting tokens.
AgentSearch is the second kind. It does the job agents usually want from a SERP API, but it returns structured JSON results (title, URL, snippet, score, domain, date) instead of a search results page.
Why agents need structured results, not raw HTML
You could point an agent at a search page and let it read the HTML. In practice that goes badly:
- Tokens. A results page is mostly markup, scripts and navigation. The ten lines the model actually needs are buried in tens of kilobytes. Every extra token costs money and pushes useful context out of the window.
- Parsing is brittle. Search pages change their layout. A scraper that worked last month returns nothing today, and the agent can't tell "no results" from "the parser broke".
- Citations. An agent that answers with sources needs a clean URL and a title for each one. Structured results hand it exactly that.
- The next step. Search is rarely the last call. The agent picks one or two URLs and reads them. A
urlfield it can pass straight to a read tool makes that loop simple. - Terms and blocking. Fetching search engine pages yourself is often against their terms and quickly runs into bot checks.
So the useful contract for an agent is small: a list of results, each with title, url and a short text snippet, plus a little metadata to rank and filter by.
What AgentSearch returns
Every search returns JSON like this (illustrative values):
{
"query": "serp api for ai agents",
"result_count": 5,
"retrieved_at": "…",
"results": [
{
"title": "…",
"url": "https://…",
"content": "…",
"score": 0.9,
"published_date": null,
"domain": "…"
}
]
}
| Field | What it is |
|---|---|
title |
The page title |
url |
The result URL, ready to pass to a read tool |
content |
A short text snippet from the page |
score |
Relevance score, useful for ranking or cutting off weak hits |
domain |
The site the result is on, handy for allow or deny lists |
published_date |
Publish date when known, otherwise null |
The request body is just query (required) and max_results (on the free relay 1 to 5, default 5). Full schemas: search OpenAPI spec and the direct x402 OpenAPI spec.
Option 1: the free relay (no key, no wallet)
The quickest way to try it. No signup, no API key, no wallet:
curl -s https://relay.agentsearchhq.com/v1/search \
-H 'content-type: application/json' -H 'X-Agent-Client: my-agent/1.0' \
-d '{"query":"serp api for ai agents","max_results":5}'
Free tier: 25 searches per IP in total, then pay per call, no key needed (shared daily capacity; paid calls have no cap). The 25 searches are a total per IP and do not reset. Once they're used up, the relay answers with the paid setup steps instead of results, so your agent knows what to do next. The X-Agent-Client header is optional; it just tells us which client is calling.
That's enough for development, demos and light use. For anything that runs on a schedule or in production, use one of the paid options below.
Option 2: pay per call with x402 on Base
The direct API at https://api.agentsearchhq.com charges per call in USDC on Base over x402, the HTTP 402 payment standard. There's no account, plan or API key: your agent's wallet signs a small payment for each call, and a call is only settled after a successful answer. Empty or failed calls aren't charged.
An unpaid request is free and shows you the exact price:
# 1) Unpaid request: HTTP 402, nothing charged. Terms are in the PAYMENT-REQUIRED header (base64 JSON).
curl -si https://api.agentsearchhq.com/x402/v1/search \
-H 'content-type: application/json' -H 'X-Agent-Client: my-agent/1.0' \
-d '{"query":"serp api for ai agents","max_results":5}' | head -20
# 2) Decode the terms (scheme exact, network eip155:8453, amount 3000 = $0.003, payTo, asset USDC)
curl -s -D - -o /dev/null https://api.agentsearchhq.com/x402/v1/search \
-H 'content-type: application/json' -H 'X-Agent-Client: my-agent/1.0' -d '{"query":"serp api"}' \
| grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 -d | python3 -m json.tool
To pay, use any x402 client. In Python, the x402 SDK handles the 402, the signature and the retry:
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.http.clients import x402HttpxClient
API = "https://api.agentsearchhq.com/x402/v1"
async def main():
account = Account.from_key(os.environ["WALLET_PRIVATE_KEY"])
client = x402Client()
register_exact_evm_client(client, EthAccountSigner(account))
async with x402HttpxClient(client, timeout=60) as http:
r = await http.post(f"{API}/search",
json={"query": "serp api for ai agents", "max_results": 5})
r.raise_for_status()
for hit in r.json()["results"]:
print(hit["score"], hit["title"], hit["url"])
asyncio.run(main())
Use a new, dedicated wallet with only a few dollars of USDC on Base, never your main wallet. The wallet setup guide walks through it, and the x402 Python tutorial and TypeScript tutorial add a spending budget.
Current direct x402 prices (from /pricing):
| Route | What it does | Price per call |
|---|---|---|
POST /x402/v1/search |
Web search: title, URL, snippet, score, domain, date | $0.003 |
POST /x402/v1/news |
Recent news articles for a query | $0.003 |
POST /x402/v1/extract |
One URL to clean markdown | $0.002 |
POST /x402/v1/search_and_read |
Search, then the top pages as markdown, in one call | $0.005 |
Official endpoints and the payment address are listed on the security page. agentsearchhq.com never asks you to connect a wallet or sign anything in your browser.
Option 3: use a package
If your agent runs in a framework, you don't need to write HTTP calls at all.
MCP (Claude Desktop, Cursor and other MCP clients):
{
"mcpServers": {
"agentsearch": {
"command": "npx",
"args": ["-y", "@agentsearchhq/agentsearch-mcp"]
}
}
}
Search works with no env block, out of the 25 free searches. To pay per call after that, set AGENTSEARCH_WALLET_PRIVATE_KEY to a new wallet and AGENTSEARCH_MODE=paid. Details: MCP server.
LangChain (Python):
pip install langchain-agentsearch
from langchain_agentsearch import AgentSearchTool
search = AgentSearchTool() # free, no key
print(search.invoke({"query": "serp api for ai agents", "max_results": 3}))
LangChain.js:
npm install @agentsearchhq/langchain @langchain/core
import { AgentSearchTool } from "@agentsearchhq/langchain";
const search = AgentSearchTool();
const raw = await search.invoke({ query: "serp api for ai agents", max_results: 3 });
console.log(raw);
n8n: install the community node n8n-nodes-agentsearch from Settings → Community Nodes, then add the AgentSearch node to your workflow. See n8n AI agent web search.
More frameworks (Vercel AI SDK, LlamaIndex, CrewAI, OpenAI Agents SDK, smolagents and others) are on the blog.
Search and read in one call
Most agents don't stop at the snippet. They search, pick the best URLs, then read those pages. With a plain SERP API that's one search call plus one read call per page.
search_and_read does both in one request: it searches, then returns the top pages as markdown.
curl -si https://api.agentsearchhq.com/x402/v1/search_and_read \
-H 'content-type: application/json' -H 'X-Agent-Client: my-agent/1.0' \
-d '{"query":"serp api for ai agents","num_results":3}'
# HTTP 402 with the terms ($0.005), nothing charged until an x402 client pays
The body takes query (required), num_results (default 3, max 5) and max_chars per page (default 8000, max 20000). Each result has title, url, snippet and the page markdown. At $0.005 it costs less than one search plus three extracts ($0.003 + 3 × $0.002 = $0.009). More: Search + Read API.
Which option should you use?
| You want to… | Use |
|---|---|
| Try it now, no setup | The free relay: 25 free searches per IP in total |
| Search from an MCP client or IDE agent | npx -y @agentsearchhq/agentsearch-mcp |
| Search from LangChain, LangChain.js or n8n | The package for your framework |
| Pay per call from your own code | Direct x402 at api.agentsearchhq.com, $0.003 per search |
| Search and read pages in one call | search_and_read, $0.005 |
What AgentSearch is not
To be clear about the fit: AgentSearch returns organic web results for agents. It does not return ads, shopping or map panels, or exact ranking positions for SEO tracking. If you need a full copy of a search engine's results page for rank tracking, a dedicated SERP scraping API is the better tool. If you need an agent to find pages and read them, structured results are what you want.
FAQ
Is AgentSearch a SERP API?
It does the job agents usually want from a SERP API: you send a query and get ranked results back. Instead of a copy of a search results page, it returns structured JSON with title, URL, snippet, score, domain and date for each result.
Do I need an API key?
No. The free relay needs no key, account or wallet: 25 searches per IP in total, then pay per call. Paid calls are signed from your own wallet over x402, so there's still no account or key.
How much does it cost?
On the direct x402 API: search and news $0.003 per call, extract $0.002, and search_and_read $0.005, paid in USDC on Base. Empty or failed calls are not charged. That's among the lowest per-call prices for agent web search. See pricing.
How many results does a search return?
On the free relay, up to 5 per search: set max_results from 1 to 5 (the default is 5). The direct x402 API's limits are in its OpenAPI spec.
Can my agent read the pages it finds?
Yes. Pass a result url to extract to get the page as markdown, or call search_and_read to search and read the top pages in one request. For pages that need JavaScript, use render.
Which frameworks are supported?
Any MCP client through @agentsearchhq/agentsearch-mcp, LangChain through langchain-agentsearch (Python) and @agentsearchhq/langchain (JavaScript), n8n through n8n-nodes-agentsearch, and anything that can make an HTTP request through the relay or the direct x402 API.
Get started
curl -s https://relay.agentsearchhq.com/v1/search \
-H 'content-type: application/json' \
-d '{"query":"serp api for ai agents","max_results":5}'
That's your first structured search, with no key. When you outgrow the free searches, switch to direct x402 at $0.003 per call. Read more about Search, Extract and Search + Read, or compare prices in Low-Cost Web Search API for AI Agents.
More from the blog
- Low-Cost Web Search API for AI Agents (2026 Pricing Compared)
- x402 Tutorial: Pay-Per-Call APIs for AI Agents, No API Key Required
- Search and Read in One Paid Call
- Add Web Search to Your AI Agent with MCP (2026 Guide)
Service pages: Web Search API · Web Extract API · Web Render API