---
title: "Web Search API for AI Agents: Four Engines Compared"
description: "Google, Brave, Bing and DuckDuckGo search endpoints compared by their recorded JSON, with one Python normaliser for agents. 1 credit per search."
url: https://perceptlayer.com/blog/web-search-api-for-ai-agents
---

[Blog](https://perceptlayer.com/blog) / [AI agents](https://perceptlayer.com/blog/category/ai-agents)

# Web Search API for AI Agents: Four Engines Compared

28 Oct 2026 Perceptlayer 7 min read

A web search API for an AI agent takes a query and returns ranked results as JSON: a title, a URL and a snippet per result. Perceptlayer has four engines behind one key (Google, Brave, Bing and DuckDuckGo), each at 1 credit per successful search. Their responses use different field names, so this post compares what each recorded response contains, then shows a short Python function that turns all four into one result shape an agent can read.

## Key takeaways

-   All four search endpoints cost 1 credit per successful call; a failed call costs nothing and returns `X-Credits-Used: 0`.
-   Google, Brave and DuckDuckGo put results in `organic_results` with `title`, `link` and `snippet`; Bing returns `data` with `title`, `url` and `description`.
-   DuckDuckGo wraps everything in `data` and takes `q` as its query parameter; the other three take `query`.
-   The recorded Google response adds `related_questions`, `related_searches` and `local_results` with ratings, phone numbers and addresses, all in the same 1-credit call.
-   A short Python normaliser maps the four shapes to `{engine, position, title, url, snippet}`, so the agent's tool returns the same shape whichever engine answered.

## What does an agent need from a search result?

An agent needs three things from each result: a title to judge relevance, a URL to cite or fetch, and a snippet to answer from without another call. Position helps it weigh results, and the engine name helps when you merge engines. Everything else in a search response is optional context that costs tokens every time the model reads it.

That's the case for normalising. If your tool hands the model the raw response, the model sees `link` from one engine and `url` from another, and nested `local_results` it may not need. A fixed, small shape keeps the tool description short and the context window clear. [Trim API Responses for LLM Context](https://perceptlayer.com/blog/trim-api-responses-llm-context) covers trimming in general; here the job is narrower: four engines, one shape.

If you want a primer on what a results page contains before comparing engines, [SERP API: What It Returns and What a Query Costs](https://perceptlayer.com/blog/serp-api-explained) covers it. This post assumes you know the idea and need to pick and wire an engine.

## How do the four search endpoints compare?

The four endpoints share a price and a purpose but differ in parameter names, response nesting and the extras they return. The table below comes from the catalogue and the recorded responses: field names are the ones that appeared in each recording, not a full schema.

|  | Google | Brave | Bing | DuckDuckGo |
| --- | --- | --- | --- | --- |
| Endpoint | `GET /v1/google-search/search` | `GET /v1/brave/search` | `GET /v1/bing/search` | `GET /v1/duckduckgo/search` |
| Query parameter | `query` | `query` | `query` | `q` |
| Results array | `organic_results` | `organic_results` | `data` | `data.organic_results` |
| URL field | `link` | `link` | `url` | `link` |
| Snippet field | `snippet` | `snippet` | `description` | `snippet` |
| Paging parameters | `start`, `page` | `page` | `page`, `num` | `start` |
| Paging info in recording | `pagination[]` with `start` values | `results_count` | `results_on_page` | `pagination.has_more`, `next_start` |
| Extras in recording | `related_questions`, `related_searches`, `local_results`, `filters` | `related_questions` with `answer` and `link`, `related_searches` | `domain` per result | `knowledge_graph.ai_answer` |
| Other parameters | `gl`, `hl`, `location`, `safe`, `tbs`, `tbm`, `device` and more | `language`, `include_html` | `site`, `filetype`, `safe`, `hl`, `include_html` | `kl`, `df`, `safe` |
| Credits per call | 1 | 1 | 1 | 1 |

Google's search endpoint takes the longest parameter list by far, and the Google Search API has six more endpoints, including AI Overview and AI Mode. The other three engines have one endpoint each.

## What do the recorded responses look like?

Each engine returns JSON with a results array, but the arrays sit at different paths and the fields have different names. These are trimmed excerpts of the recorded responses, with `…` where we cut. Where a recorded result named a person or a competing product, its title and snippet are cut too.

### Google

```bash
curl "https://api.perceptlayer.com/v1/google-search/search?query=best+restaurants+in+Berlin&hl=en&safe=off" \
  -H "X-API-Key: $API_KEY"
```

```json
{
  "search_information": {
    "query_displayed": "best restaurants in Berlin",
    "organic_results_count": 6
  },
  "organic_results": [
    {
      "position": 1,
      "title": "The Best Restaurants in Berlin - Food Guide & Map",
      "link": "https://andershusa.com/best-restaurants-berlin-germany-guide/",
      "displayed_link": "https://andershusa.com › best-restaurants-berlin-german...",
      "snippet": "Dec 3, 2025 — …",
      …
    },
    …
  ],
  "related_questions": [
    {
      "question": "What is the coolest restaurant in Berlin?",
      …
    },
    …
  ],
  "local_results": {
    "places": [
      {
        "position": 1,
        "title": "BLESS Restaurant",
        "rating": 4.8,
        "reviews": 2400,
        "price": "€20–70",
        "address": "Hausvogteipl. 10, 10117 Berlin, Germany",
        …
      },
      …
    ],
    …
  },
  …
}
```

The `local_results.places` block matters for agents: a question like "where should I eat in Berlin" gets ratings, review counts and addresses without a second call.

### Brave

```json
{
  "search_information": {
    "query_displayed": "best web scraping api"
  },
  "organic_results": [
    {
      "position": 1,
      "title": "…",
      "link": "…",
      "displayed_link": "…",
      "snippet": "…",
      "source": "…"
    },
    …
  ],
  "related_questions": [
    {
      "question": "…",
      "answer": "…",
      "link": "…",
      "title": "…"
    },
    …
  ],
  "results_count": 20,
  "engine_used": "brave",
  …
}
```

Brave's result fields line up with Google's: `position`, `title`, `link`, `snippet`. Its `related_questions` entries carry an `answer` and the `link` it came from, which an agent can quote with a citation.

### Bing

```json
{
  "data": [
    {
      "position": 2,
      "title": "BEST | English meaning - Cambridge Dictionary",
      "description": "BEST definition: 1. of the highest quality, or being the most suitable, pleasing, or effective type of thing or…. Learn more.",
      "url": "https://dictionary.cambridge.org/dictionary/english/best",
      "domain": "dictionary.cambridge.org"
    },
    …
  ],
  "results_on_page": 10,
  "source": "bing"
}
```

The recorded Bing request was the same query as Brave's, "best web scraping api", and the two results in the recording are about the word "best", not about scraping APIs. That's what came back at the time of the call. It's a reason to have the agent check relevance from the title and snippet before it answers, whichever engine you use.

### DuckDuckGo

```json
{
  "success": true,
  "data": {
    "search_parameters": {
      "q": "…",
      "kl": "us-en",
      "safe": true,
      "start": 0
    },
    "organic_results": [
      {
        "position": 1,
        "title": "…",
        "link": "…",
        "snippet": "…",
        "display_url": "…",
        "favicon": "…"
      },
      …
    ],
    "pagination": {
      "current": 1,
      "has_more": true,
      "next_start": 10,
      "next": 2
    },
    …
  },
  "meta": {
    "duration_ms": 2169,
    "endpoint_family": "web_search"
  }
}
```

DuckDuckGo nests results one level down, under `data`. Its `pagination` block gives `has_more` and `next_start`, so a paging loop can pass `next_start` back as `start`. One recorded snippet contained `&amp;` rather than `&`, so unescape HTML entities before the model reads it.

## How do you normalise four engines into one result shape?

Write one function per engine that reads only the fields seen in the recordings, then return a list of dicts with the same five keys. The agent's tool calls a single `web_search(query, engine)` function and never sees engine-specific names. Any field the recordings didn't show is treated as unknown and read with `.get()`.

```python
import html
import os

import requests

BASE = "https://api.perceptlayer.com"
HEADERS = {"X-API-Key": os.environ["API_KEY"]}

ENGINES = {
    "google": ("/v1/google-search/search", "query"),
    "brave": ("/v1/brave/search", "query"),
    "bing": ("/v1/bing/search", "query"),
    "duckduckgo": ("/v1/duckduckgo/search", "q"),
}

def _rows(engine, body):
    if engine in ("google", "brave"):
        return body.get("organic_results", []), "link", "snippet"
    if engine == "bing":
        return body.get("data", []), "url", "description"
    return body.get("data", {}).get("organic_results", []), "link", "snippet"

def web_search(query, engine="google", limit=5):
    path, param = ENGINES[engine]
    resp = requests.get(BASE + path, params={param: query}, headers=HEADERS, timeout=60)
    if resp.status_code != 200:
        err = resp.json().get("error", {})
        return {"error": err.get("code"), "engine": engine}
    rows, url_key, snippet_key = _rows(engine, resp.json())
    results = []
    for row in rows[:limit]:
        results.append({
            "engine": engine,
            "position": row.get("position"),
            "title": html.unescape(row.get("title") or ""),
            "url": row.get(url_key),
            "snippet": html.unescape(row.get(snippet_key) or ""),
        })
    return {"results": results, "credits_used": resp.headers.get("X-Credits-Used")}

if __name__ == "__main__":
    for r in web_search("best restaurants in Berlin")["results"]:
        print(r["position"], r["title"], r["url"])
```

Errors come back as an HTTP status and a JSON body with `error.code`, so the function returns the code instead of raising. The model can then read `rate_limited` or `source_error` and decide whether to try another engine. The [errors docs](https://docs.perceptlayer.com/errors) list every code, and [Handle Web Data API Errors in Python](https://perceptlayer.com/blog/handle-web-data-api-errors-python) covers retries and timeouts.

### Should the agent fall back to another engine?

A fallback chain is cheap because failed calls are free. If Google returns a `source_error`, calling Brave next costs 1 credit for the successful call and nothing for the failed one. Keep the chain short (two engines is enough) and cap it in code, not in the prompt. For 429 responses, wait for the seconds in `Retry-After` instead of switching engines, because the rate limit is per account and applies to all four.

### Should the agent merge results from two engines?

Merging two engines gives the agent a second set of sources for 2 credits per question. Deduplicate on `url` after normalising, keep the better `position`, and pass the engine name through so the model can see where each result came from. It's worth it for research questions where one engine's top results may be thin; for a quick factual lookup, one engine is enough.

## What does a search cost an agent?

Every search costs 1 credit on success and 0 on failure, so an agent's search bill is its number of successful searches. The free tier gives 100 credits after you verify your email, and paid credits come in prepaid packs from 10,000 credits upward. `X-Credits-Used` and `X-Credits-Remaining` come back on every successful response, so the tool can report spend as it goes.

Worked examples:

-   An agent that answers 300 questions a day with one search each: 300 × 30 days × 1 credit = 9,000 credits a month, inside the Starter pack's 10,000.
-   The same agent merging two engines per question: 300 × 2 × 30 × 1 credit = 18,000 credits a month, inside the Build pack's 50,000.
-   A fallback that fires on 5% of questions adds about 450 credits a month at 300 questions a day, and only for the fallback calls that succeed.

Free accounts get 1 request a second and paid accounts at least 5, shared by every key on the account. See [pricing](https://perceptlayer.com/pricing) for what credits cost and the [rate limits docs](https://docs.perceptlayer.com/rate-limits) for the headers.

## Which search engine should your agent use?

Pick by the question your agent answers most, because the four differ in extras and parameters more than in the basic result. Every verdict below costs the same, 1 credit per successful search.

-   **General question answering and citations**: Google. The recorded response carries organic results plus `related_questions` and `related_searches`, and the endpoint takes `gl`, `hl` and `location` for country and language.
-   **Local questions** (restaurants, shops, services near a place): Google. `local_results.places` returns `rating`, `reviews`, `price`, `phone` and `address` in the same call.
-   **Answers with a cited source**: Brave's `related_questions` pair an `answer` with the `link` it came from.
-   **Queries that need the `site` or `filetype` parameter**: Bing is the only one of the four with those parameters.
-   **Paging until results run out**: DuckDuckGo's `pagination.has_more` and `next_start` make the loop condition explicit.
-   **A second opinion**: run Google plus one other engine, normalise, and deduplicate on `url`, for 2 credits per question.

Through MCP, the agent doesn't need your wrapper at all: `search_endpoints` and `get_endpoint` find and describe these endpoints for free, and `call_endpoint` runs them. The [AI agents docs](https://docs.perceptlayer.com/ai-agents) cover setup. To compare the engines on your own queries first, run each one in the playground on the [Google Search API](https://perceptlayer.com/apis/google-search), [Brave Search API](https://perceptlayer.com/apis/brave), [Bing API](https://perceptlayer.com/apis/bing) and [DuckDuckGo API](https://perceptlayer.com/apis/duckduckgo) pages, then [get a free API key](https://perceptlayer.com/signup).

## APIs in this post

-   [Google Search **1 credit per call** · 7 endpoints](https://perceptlayer.com/apis/google-search)
-   [Brave Search **1 credit per call** · 1 endpoint](https://perceptlayer.com/apis/brave)
-   [Bing **1 credit per call** · 10 endpoints](https://perceptlayer.com/apis/bing)
-   [DuckDuckGo **1 credit per call** · 3 endpoints](https://perceptlayer.com/apis/duckduckgo)

## Frequently asked questions

### How much does a web search API call cost?

Each of the four search endpoints costs 1 credit per successful call. A failed call costs nothing and returns `X-Credits-Used: 0`. Every account gets 100 free credits after verifying an email address, which is 100 searches. Credits beyond that come in prepaid packs; the [pricing](https://perceptlayer.com/pricing) page has what they cost.

### Do the four engines return the same results?

No. The recorded responses differ in fields as well as in which pages come back. Google, Brave and DuckDuckGo use `link` and `snippet`, Bing uses `url` and `description`. Results are returned as found at the time of the call, so test your agent's typical queries on each engine before you pick one.

### Which parameter holds the search query?

Google, Brave and Bing take `query` as a required parameter. DuckDuckGo takes `q` instead, also required. A request that fails for any reason costs nothing. If you wrap the engines in one function, map the parameter name per engine, as the `ENGINES` table in the normaliser above does, so the agent only ever passes a query string.

### Can an AI agent call these search endpoints over MCP?

Yes. The MCP server at `https://perceptlayer.com/mcp` exposes `search_endpoints` and `get_endpoint`, which look up the catalogue for free, and `call_endpoint`, which runs an endpoint and spends credits only on success. The agent can find all four search endpoints that way. [How to Add an MCP Server to Claude Desktop and Cursor](https://perceptlayer.com/blog/add-mcp-web-data-tools-claude-desktop) covers client setup.

### What happens when a search is rate limited?

The call returns 429 with a `rate_limited` error code, a `Retry-After` header giving the seconds to wait, and no charge. Limits are per account, shared by every key, so switching to another engine doesn't help. Wait the given seconds and retry. [HTTP 429 Too Many Requests](https://perceptlayer.com/blog/http-429-too-many-requests) covers backoff patterns.

web search ai agents search api google bing duckduckgo

## More from the blog

1.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 18 Sept 2026 Updated 10 Nov 2026 Perceptlayer 7 min read
    
    ## [How to Add an MCP Server to Claude Desktop and Cursor](https://perceptlayer.com/blog/add-mcp-web-data-tools-claude-desktop)
    
    Add the Perceptlayer MCP server to Claude Desktop or Cursor with an API key header, run a first Google search, and check only successful calls cost credits.
    
2.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 7 Sept 2026 Perceptlayer 8 min read
    
    ## [OpenAI Agents SDK with a Remote MCP Server for Web Data](https://perceptlayer.com/blog/openai-agents-sdk-mcp-server)
    
    Connect the OpenAI Agents SDK to a Streamable HTTP MCP server with a Bearer header, cap call\_endpoint at 3 calls a question, and count credits per run.
    
3.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 31 Jul 2026 Perceptlayer 9 min read
    
    ## [Add Web Search to an OpenAI Agent: Python Tool Calls](https://perceptlayer.com/blog/openai-agent-web-search-tool-call)
    
    Add web search to an OpenAI agent in Python: one web\_search tool over live Google results, a tool-call loop and a cap of 1 credit per search.
