Engineering

Production Search API Guide for AI Applications

The demo works with one search and no failures. Production is where the rate limits, the timeouts, the retries and the 3am page live. Here is the checklist, with the reasoning.

AgentSearch · Updated November 2026 · 11 min read

Everything in this guide applies to any search API. What is specific to AgentSearch is called out where it comes up.

Decide what the search is for before you build anything

The single most expensive mistake in agent search is building a pipeline whose purpose nobody can state. "Give the model the web" is not a purpose; it produces ten pages of context per question and no way to tell whether it helped.

Write down the question the search answers, and the shape of an acceptable answer. That sentence becomes your evaluation set, and it is what tells you whether a change to the query, the limit or the fetch strategy made things better. Without it, every tuning decision is a guess and every regression is invisible.

Rate limits are a design constraint, not an incident

AgentSearch's limit is per account and per plan: 2 requests per second on Free, 20 on Pro, 50 on Team. It is a hard ceiling, and an agent that bursts past it gets a 429.

The naive client retries immediately and makes it worse. A retry storm on a rate-limited endpoint is how a small burst becomes an outage. Use exponential backoff with jitter, and honour Retry-After when it is present:

import random, time, httpx def with_backoff(fn, attempts=4): for attempt in range(attempts): try: return fn() except httpx.HTTPStatusError as exc: status = exc.response.status_code # 400 and 422 are the request's fault. Retrying changes nothing. if status not in (429, 502, 503, 504): raise if attempt == attempts - 1: raise delay = float(exc.response.headers.get("Retry-After", 0)) or ( 2 ** attempt + random.random() ) time.sleep(delay)

Note which statuses are in that list. A 400 means your query was rejected; a 422 means your body did not validate. Retrying either is a waste of a round trip and, worse, hides the bug.

Set your own deadline, and know what to do when you hit it

A search that has not answered in 30 seconds is a search that will not answer. The search gives up and answers 504. Your client needs its own deadline below that, or you will spend 30 seconds waiting for a timeout that was guaranteed.

Then decide the fallback while you are calm. The options, roughly in order of preference: answer from cache; answer from the summaries of a smaller search; answer without search and say so; fail the turn. What you should not do is silently return an empty result set - the model cannot tell "nothing on the web" from "the call failed", and it will answer confidently either way. A 503 comes with a message that says what failed; pass that message through.

Cache what you can, and cache it honestly

AgentSearch caches searches for five minutes, keyed by query, result count and whether the body was requested. That covers the common case of the same question asked twice in a conversation.

The question worth deciding deliberately is whether a cached answer should still count against your allowance. AgentSearch says no: a cache hit does not consume a search. The reasoning is that the allowance is about how much search work you asked for, and a repeat question is the same question - while the reading still counts, because you read the same text again and that is your cost, not ours.

Give the model a way to reject a result

An agent that must cite everything will cite the first result, which is often a listicle. An agent that can see a quality score will skip it. AgentSearch returns three signals per result: our quality_score (0-1), the engine's authority rating (0-4) and its rerank_score (0-3), plus the publication date as a real field.

Passing those to the model is cheap and changes behaviour measurably. The instruction is one line - "prefer results with quality_score above 0.75, and say so when nothing reaches it" - and it turns an agent that always answers into one that can decline.

Treat the fetch as a separate, riskier step

A search returns pages from an index. A fetch reaches out to an arbitrary URL on the internet, and that URL might be hostile, enormous, slow, or a login page.

What a production fetch layer needs:

Do not let your agent fetch a URL that came out of an untrusted page without a check. Prompt injection does not need a clever payload if the model will fetch any URL it reads.

Keep the two meters separate

AgentSearch meters searches and page reads separately - 100 and 20 a month on Free, 3,000 and 1,000 on Pro, 30,000 and 10,000 on Team - and a call beyond the allowance is priced at $2.5 per 1,000 and still served, rather than refused mid-conversation.

That separation is not cosmetic. It tells you where the agent spends its time: an agent doing five searches and one fetch has a search problem, and an agent doing one search and eight fetches has a read problem. You cannot see that if both are one number. The usage endpoint gives you both, per feature, with what is left and when it resets.

Log the five things that matter

Do not log the query text if your privacy promise says you do not: AgentSearch stores usage metadata without query content, and your own logs should match that promise or you have just broken it.

Ship it

Start with the Free plan, run your own evaluation set against it, and only then pick a tier. The cheapest search API in the world is the one that answers the questions your users actually ask.

100 searches and 20 fetches a month, free

No card, no trial clock. If it does not survive your own questions, nothing will.

Get a free API key

Related: the true cost of naive search, and MCP search integration.