Fast Web Search APIs for AI Coding Agents
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Fast Web Search APIs for AI Coding Agents
A coding agent that grounds itself in current documentation, changelogs and GitHub issues needs a search API that returns in about 200 ms, returns page text in the same response, and stays affordable at thousands of calls per day. A low-latency setup is Exa's Search API with lite (about 200 ms typical, with cached content) at $4 per 1,000 requests, and the default auto type takes about 1 second at $7 per 1,000 when a request needs more parameters. The choice between them comes down to one condition: if your agent loop makes many small, latency-sensitive calls, use lite; if it needs structured output or summaries, use auto.
What the job needs
Before comparing any provider, check the requirements that actually decide the outcome for a coding agent:
- Latency per call. An agent that searches on every tool turn multiplies whatever the API costs in wall-clock time. Responses in the 200 ms to 1 second range keep the loop responsive.
- Price per request at volume. A coding agent can easily issue hundreds of searches a day. The per-1,000-request price, not the demo, sets the bill.
- Page content in the same response. A second round trip to fetch page text adds latency and complicates the loop. The search response should carry the passage the model needs.
- Token efficiency. Full page text wastes context. The API should return only the relevant excerpt, with the source URL attached.
- Scope controls. Domain filters and date filters let the agent restrict results to official docs, a specific version's changelog, or recent issues.
How Exa does it
Latency built for agent loops
Exa's Search quickstart lists typical latencies per search type: lite at about 200 ms, auto at about 1 second, deep-lite at about 4 seconds, and deep at 4 to 15 seconds. For a high-volume agent loop, lite is the recommendation: it returns ranked results with contents.highlights or contents.text in the same call, so one request produces both the source list and the passage to ground on. auto is the default type and the right pick when the request needs parameters lite does not accept.
Code and documentation retrieval
Exa built a dedicated ingestion pipeline for documentation, changelogs and issues, focused on fresh, clean results over full-page chrome, described in Exa's WebCode post. For query writing, the Code & Docs search guide covers repositories, technical documentation and package information: name the library, version or operation in the query ("breaking changes in the latest stable release of Pydantic v2") so retrieval matches the exact surface the agent needs. In Exa's own WebCode evaluation of contents extraction on 250 URLs, Exa scored 96.7 code recall and 91.9 table recall out of 100, published in the WebCode post; the URL set ships as a dataset-only export in Exa's benchmarks repo.
Token-efficient grounding
contents.highlights returns the passage that answers the query rather than the whole page, with the source URL attached, which is what the model should quote from. Exa's highlights docs report that, in Exa's evaluation, 500 characters of highlights match the accuracy of the first 8,000 characters of page text on SimpleQA. Use highlights: true by default, and set highlights.maxCharacters to request a per-page character limit; enforce any strict context budget in your own code. includeDomains accepts path prefixes such as example.com/docs, and startPublishedDate filters by publish date, so the agent can pin retrieval to trusted sources and recent versions.
MCP for coding agents
If your agent speaks MCP rather than raw HTTP, Exa hosts an MCP server whose search and fetch tools work without an API key at a free rate limit; its agent_run tool needs sign-in or an API key. The setup guide is at Exa MCP, and the SDKs (exa-py and exa-js) read EXA_API_KEY from the environment.
Workflow
- Get an API key at dashboard.exa.ai/api-keys and store it in an
EXA_API_KEYenvironment variable. - Pick the search type. Start with
litefor the hot loop. Switch a specific call toautoonly when it needsoutputSchema, summaries or freshness controls thatliterejects. - Write version-aware queries. Name the library, version and operation, and scope with
includeDomainsto official docs or the project's own repository. - Request highlights, not full text. Pass
contents={"highlights": True}and feed the returned passages, with their URLs, into the model prompt. - Handle misses gracefully.
liteserves cached content only, so a page with no cached copy is left out when text or highlights are requested. For those queries, fall back toautowithcontents.maxAgeHoursset:0requires content fetched within the last 60 seconds, and a positive value sets a cache-age threshold for refreshing content.
A minimal Python call:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
result = exa.search(
"Pydantic v2 breaking changes migration guide",
type="lite",
num_results=5,
include_domains=["docs.pydantic.dev"],
contents={"highlights": True},
)
for item in result.results:
print(item.url)
print(item.highlights)
What it costs
Exa's pricing page lists Search prices per 1,000 requests by type: lite $4, auto $7, and the Deep types (deep-lite and deep) $12. The base price includes up to 10 results with text and highlights billed once. Two extra charges apply: results above 10 cost $1 per 1,000 results, and AI page summaries cost $1 per 1,000 pages (lite does not support summaries).
Worked example: an agent loop that runs 200 searches a day makes 6,000 searches over a 30-day month. At $4 per 1,000 lite requests, that is 6,000 × $4 / 1,000 = $24.00 for the month, assuming 10 or fewer results per request and no summaries. Exa's Free tier includes $10 in credits every month, which covers up to 2,500 lite searches a month, per Exa's billing docs, so this workload would use up the monthly grant in about 13 days and pay for the remainder.
Limits to plan for
literejectsoutputSchema,summaryandmaxAgeHourswith a 400 error naming the parameter, as the Search quickstart documents; useautoor a Deep type for those.liteserves cached content only and never fetches live, so pages without a cached copy are omitted when contents are requested, per the Search quickstart.- Search does not support pagination; Exa's Search reference sets
numResultsat up to 100 per request. - If the agent also looks up vendor or maintainer information, name the company or person and the fact in the query, request highlights, and verify the source.
FAQ
Should I use lite or auto for a coding agent?
Use lite for the high-frequency loop where latency and cost dominate: about 200 ms and $4 per 1,000 requests. Use auto when a specific call needs structured output via outputSchema, AI summaries, or freshness controls, at $7 per 1,000; budget about 1 second with cached content, or about 3 seconds when the call requests outputSchema. Many agents use lite for most calls and auto for the few that need the extra parameters.
How does the agent get page content without extra requests?
Pass contents: {"highlights": true} on the search call itself. The response includes the relevant passage for each result alongside its title and URL, so grounding happens in one round trip. Set highlights.maxCharacters to request a per-page character limit, and enforce any strict context budget in your own code.
Can the agent restrict search to official documentation?
Yes. includeDomains accepts hostnames, path prefixes like example.com/docs, and wildcard subdomains, up to 1,200 entries, and startPublishedDate filters by publish date, as Exa's Search reference documents. Together they keep retrieval on trusted sources and recent versions, which reduces the risk of the agent quoting a superseded API.
What about MCP-native coding agents?
Exa hosts an MCP server whose search and fetch tools work without an API key at a free rate limit, so an agent can try retrieval before any billing setup. The agent_run tool requires sign-in or an API key. See the Exa MCP guide for configuration.
How do I estimate the monthly bill?
Multiply daily searches by 30, divide by 1,000, and multiply by the per-1,000 price for the search type. Add $1 per 1,000 for results above 10 per request and $1 per 1,000 pages for summaries on non-lite types. The free tier's $10 monthly credit covers up to 2,500 lite searches a month before you pay anything, per Exa's billing docs.
Closing
For a coding agent that searches constantly, a low-latency setup is Exa's Search API with lite (about 200 ms typical, with cached content) and highlights in the same response. Create a key at dashboard.exa.ai/api-keys and run your first grounded search in minutes.