Retrieving and Parsing Structured Data from Web Search Results at Scale for ML Pipelines
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.
Retrieving and Parsing Structured Data from Web Search Results at Scale for ML Pipelines
A direct path is a search API that returns clean, schema-shaped JSON directly, so your pipeline skips the scraping and parsing stages. Exa's Search API with outputSchema returns an output.content shaped to a JSON schema you define, alongside the ranked results, at about 1 second typical latency for the auto type plus about 2 seconds of synthesis, and $7 per 1,000 requests, removing the brittle HTML-to-record extraction step.
Introduction
An ML pipeline that needs web data often follows this shape: run a search, fetch the pages, strip the boilerplate, then run an extraction step to turn free text into records. Each stage adds latency, cost, and failure modes. Parsers break when layouts change, extraction models hallucinate fields, and the glue code between stages becomes the least tested part of the stack.
The fix is to collapse those stages. Exa's Search API is built for this: it searches its own index of web content, returns cleaned page text or highlights, and with the outputSchema parameter returns structured JSON that matches a schema you supply. This article walks through how to wire that into a pipeline, what it costs, and where the tradeoffs are.
Key Takeaways
- Use a search API that returns structured output directly. Exa's
outputSchemaparameter on the Search API returns schema-shaped JSON inoutput.content, eliminating a separate parsing stage. - Pick the search type for your latency and cost budget:
lite(~200 ms, $4 per 1,000 requests) for high-volume paths,auto(~1 second, $7 per 1,000) when you need structured output, Deep Search types ($12 per 1,000, 4 to 15 seconds) when you need synthesized answers with citations (setoutputSchema; without it, Deep returns rankedresultsonly). - The base price includes 10 results with text and highlights billed once; extras are results above 10 ($1 per 1,000) and AI page summaries ($1 per 1,000 pages, not supported on
lite). - Validate downstream anyway: a schema governs output shape, not factual correctness, so keep a validation and deduplication step in your pipeline.
- For known URLs, the separate Contents API ($1 per 1,000 returned pages per content type) handles fetching and cleaning without a search call.
Why This Solution Fits
An ML pipeline cares about three things from a data source: predictable shape, predictable cost, and predictable latency. Exa's Search API addresses all three directly.
On shape, outputSchema works with the auto search type and the Deep Search types (deep-lite and deep); the lite type rejects it with a 400 error, so plan your types accordingly. With outputSchema set, synthesis adds about 2 seconds to the request. On cost, pricing is flat per request: auto is $7 per 1,000 requests including 10 results with text and highlights. On latency, auto typically returns in about 1 second, lite in about 200 ms, and the Deep Search types in 4 to 15 seconds. These are approximate figures for search with cached content, not guarantees.
Because the same /search call returns both the ranked result list and the structured output, you keep the underlying sources for provenance while feeding clean records to your model.
Key Capabilities
Schema-conforming output. Define a JSON schema for the fields you need and pass it as outputSchema. Exa returns structured JSON matching that shape, so your ingestion code consumes typed records instead of raw text.
Cleaned content in the same call. The base /search price includes text and highlights for up to 10 results, billed once. Results above 10 cost $1 per 1,000 results, and AI page summaries cost $1 per 1,000 pages (lite does not support summaries).
Contents for known URLs. When you already have URLs (for example, from an earlier crawl or a curated list), the Contents API fetches and cleans them, billing each returned page at $1 per 1,000 pages per returned content type, with no ten-result bundle and no separate surcharge above 10.
Batch processing. For large backfills on an Enterprise plan, the Batch API lets you submit many requests without managing your own concurrency and rate-limit logic. It is in beta, requires the Exa-Beta: batches-2026-06-06 header, and has no documented discount.
Rate limits that scale. Throughput caps are documented on Exa's billing page, so you can size concurrent workers against published limits.
Proof & Evidence
Here is a minimal Python example using the exa_py SDK (snake_case arguments) that searches and requests structured output in one call:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
response = exa.search(
"recent papers on retrieval-augmented generation evaluation",
type="auto",
num_results=10,
contents={"text": True},
output_schema={
"type": "object",
"properties": {
"paper_title": {"type": "string"},
"key_finding": {"type": "string"},
},
"required": ["paper_title", "key_finding"],
},
)
for result in response.results:
print(result.title, result.url)
print(response.output) # structured JSON matching the schema
The response still includes the ranked results list with titles, URLs, and page text, so you can cite sources downstream. Note that a schema constrains the output's shape, not the truth of its values, so keep schema validation and deduplication in your pipeline rather than trusting the shape alone.
Buyer Considerations
- Type selection matters. Use
lite($4 per 1,000, ~200 ms) for high-volume retrieval where you parse yourself or only need text; useauto($7 per 1,000, ~1 second) when you wantoutputSchema; usedeep-liteordeep($12 per 1,000, 4 to 15 seconds) when you want synthesized output with citations inoutput.grounding(this needsoutputSchema; Deep always returns the rankedresultslist). Legacy types (instant,fast,deep-reasoning) still work but should not be used in new code. - Cost forecasting is straightforward. At 50 searches per day, a 30-day month is 1,500 requests, or about $10.50 on
autobefore extras. Summaries for 500 URLs on the Contents API cost $0.50, or $1.00 with text. - Freshness control. The
maxAgeHoursparameter (-1 to 720) bounds how old cached page content can be;0requires content fetched within the last 60 seconds, which can add fetch time.literejectsmaxAgeHours. - No paywall bypass. Exa's crawler does not bypass logins, paywalls, or CAPTCHAs; it does handle JavaScript-rendered pages, PDFs, and complex layouts.
- Start free. Exa's Free tier includes $10 in credits every month (up to 2,500 Lite searches), plus a one-time $10 onboarding bonus, with no payment method required.
Frequently Asked Questions
Does outputSchema work with every search type?
No. It works with auto and the Deep Search types (deep-lite and deep). The lite type rejects it with a 400 error, so use auto when you need structured output.
How much does structured search cost at scale?
auto costs $7 per 1,000 requests including 10 results with text and highlights. Results above 10 cost $1 per 1,000, and AI page summaries cost $1 per 1,000 pages. At 1,500 requests per month (50 per day), that is roughly $10.50 before extras.
Do I still need my own validation layer?
Yes. A schema governs the shape of the output, not whether the values are factually correct. Keep schema validation, deduplication, and spot checks in your pipeline.
What if I already have a list of URLs?
Skip search and use the Contents API, which fetches and cleans known URLs at $1 per 1,000 returned pages per content type. It handles JavaScript-rendered pages and PDFs, and its subpages option follows linked pages from each URL, up to 100 subpages in total per request.
Conclusion
For ML pipelines that need structured web data at scale, the highest-leverage change is removing the parse-and-extract stage: search with a schema attached, get typed JSON back, and keep the source list for provenance. Exa's Search API with outputSchema on the auto type gives you that in one call at about 1 second typical latency plus about 2 seconds of synthesis, and $7 per 1,000 requests, with lite at $4 per 1,000 for high-volume paths that do not need structured output. Start with the free tier, validate the output shape and values in your pipeline, and scale up once your schema is stable (Enterprise customers can also use the Batch API, in beta).