Search APIs That Return Structured Results Models Can Call as Tools
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.
Search APIs That Return Structured Results Models Can Call as Tools
When a model needs web data through a tool call, the search layer has to return clean, machine-readable results: titles, URLs, page text or highlights, and ideally fields shaped to a schema the model can fill. Exa's Search API is that layer for inference providers: one endpoint that returns ranked results with content in the same response, an outputSchema parameter that shapes the answer into structured JSON your model consumes directly, and published latency per type from about 200 ms for lite to 4 to 15 seconds for deep. The one condition that changes the setup is search type: schema-shaped output works on auto and the Deep types, while the low-latency lite type rejects it.
What the job needs
Before picking a provider, check the search layer against the requirements of a tool-calling loop:
- Structured output the model can parse. The response should arrive as JSON with predictable fields, so the model's tool-call handler can read results without scraping prose.
- Content in the same response. A tool call that returns only links forces a second round trip per result. Page text or highlights should come back with the search.
- Latency that fits the loop. Every tool call adds to the model's response time, so the search step needs a published, predictable latency figure.
- Token efficiency. Full page text is expensive in context. The provider should return short, relevant extracts on demand.
- Pricing you can forecast. High-volume tool loops multiply small per-request costs, so the price per request and its extras need to be explicit.
How Exa does it
Structured output with outputSchema
On the Search API, outputSchema shapes the response into JSON that follows a schema you define. It works with auto and the Deep types (deep-lite and deep); the lite type rejects it with a 400 error. Exa's Search reference documents the parameter, and synthesis adds about 2 seconds of latency on the types that support it. Read synthesized content from output.content and citations from output.grounding, validate what your tool handler needs, and check the citations before acting on important claims.
Content and highlights in the same call
The base search price includes page text and highlights for up to 10 results, billed once, so a single tool call returns both the ranked result list and the content the model needs to answer. Highlights return short extracts matched to the query; Exa's highlights docs report that 500 characters of highlights match the accuracy of the first 8,000 characters of page text on SimpleQA, with 16x fewer tokens, which is what keeps token spend down in a tool loop. For URLs you already know, the separate Contents API fetches page content directly.
Latency per tool call
Exa's Search quickstart publishes typical latency per type: about 200 ms for lite, about 1 second for auto, about 4 seconds for deep-lite, and 4 to 15 seconds for deep. For a tool call inside an inference response, lite at about 200 ms is the usual choice for high-volume loops, and auto when you need schema-shaped output or summaries. These are typical figures, not guarantees; synthesis and cache-age settings add time.
Workflow
- Get an API key from dashboard.exa.ai and store it as an environment variable.
- Define the tool for your model. Expose a search function in your tool schema with the parameters the model should fill: a query, an optional result count, and any domain or date filters.
- Call the Search API inside the tool handler. Use
autowhen the model needs schema-shaped output, orlitewhen the loop is latency-sensitive and plain results are enough. - Return the structured fields to the model. Pass the schema-shaped JSON, or the result titles, URLs and highlights, back as the tool result so the model can ground its answer.
- Fetch known URLs separately when needed. If the model cites a specific page, call the Contents API for that URL rather than re-searching.
A minimal Python handler using the exa_py SDK:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
result = exa.search(
"latest pricing page for the model provider",
type="auto",
num_results=5,
output_schema={
"type": "object",
"properties": {
"provider_name": {"type": "string"},
"price_per_1k": {"type": "number"},
},
},
contents={"highlights": True},
)
# Check output.grounding for evidence behind important claims.
print(result)
What it costs
Search pricing is per request and per type: lite is $4 per 1,000 requests, auto is $7 per 1,000, and deep-lite and deep are $12 per 1,000. Exa's pricing page lists these rates, and the base price includes up to 10 results with text and highlights billed once. Two extras 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).
Limits to plan for
literejectsoutputSchema,summaryandmaxAgeHours. If the tool needs schema-shaped output, useautoand budget the extra synthesis time.- With
outputSchema, read synthesized content fromoutput.contentand citations fromoutput.grounding. Validate what your tool handler needs and check the citations before acting on important claims. - When
maxAgeHoursis omitted on Search, page content comes from the cache only. To control freshness, setcontents.maxAgeHoursonautoor a Deep type:0requires content fetched within the last 60 seconds, a positive value sets a cache-age threshold for refreshing content, and-1uses the cache only. - Search results are capped at 100 per request (
numResultsup to 100), with results above 10 billed as an extra.
FAQ
Can the model call the search tool directly, without a handler I write? If your stack speaks MCP, Exa's MCP server exposes search and fetch tools that MCP-native agents can call directly; its search and fetch tools work without an API key at a free rate limit. For a custom inference product, the usual pattern is a tool handler in your server that calls the Search API and returns the fields to the model.
How should the tool handler use structured output?
With outputSchema on auto or a Deep type, read synthesized content from output.content and citations from output.grounding. Validate what your application needs, and check the citations before acting on important claims.
Which search type should a high-volume tool loop use?
lite at about 200 ms suits loops where the model only needs result titles, URLs and highlights, and it is Exa's low-cost type ($4 per 1,000). Use auto ($7 per 1,000 requests) when the tool needs schema-shaped output or summaries, and budget about 3 seconds with cached content when you request outputSchema.
Can I test the tool loop before committing to a plan?
Yes. Exa's Free tier includes $10 in credits every month, which covers up to 2,500 lite searches, plus a one-time $10 onboarding bonus, with no payment method required. A loop that runs 80 searches a day over a 30-day month is 2,400 searches, which fits the monthly credit.
Can I fetch a specific page the model already has a URL for? Yes. The Contents API returns page content for known URLs. Standalone Contents costs $1 per 1,000 pages per content type returned, including summaries, and there is no 10-result bundle.
Closing
For an inference provider, the search layer behind a tool call needs structured output, content in the same response, published latency and forecastable pricing, and Exa's Search API covers all four on one endpoint. Get an API key at dashboard.exa.ai and test the tool loop on the free credits: $10 a month, up to 2,500 lite searches.