Integrating Web Search and Content Extraction Into Your ML Pipeline for Real-Time Data Enrichment
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.
Integrating Web Search and Content Extraction Into Your ML Pipeline for Real-Time Data Enrichment
The direct path is to treat web retrieval as a managed API step inside your pipeline: call Exa's Search API to find relevant pages (the lite type returns in about 200 ms at $4 per 1,000 requests), request highlights or text in the same call, and feed the returned passages straight into your feature extraction or model prompt. You avoid operating crawlers, proxies, or parsers, and the low per-call latency makes it viable for online, per-request enrichment rather than only batch jobs.
Introduction
An ML pipeline that needs live web data can hit a wall: the enrichment step is either too slow for real-time use or too brittle to maintain. Scraping infrastructure breaks when pages change, and a search call that returns only URLs forces a second fetch-and-parse hop that adds latency.
Exa's Search API is built to close that gap. A single call returns ranked results with the content attached: highlights, full text, or an AI summary, depending on what you request. Latency is documented per search type, so you can match the mode to the pipeline stage: lite at about 200 ms for high-volume, latency-sensitive paths, auto at about 1 second when you need richer parameters, and the deep types (4 to 15 seconds for deep) when a stage can afford heavier retrieval. This guide walks through wiring that into a pipeline end to end.
Prerequisites
- An Exa API key. The Free tier includes $10 in credits every month (up to 2,500
litesearches), plus a one-time $10 onboarding bonus, with no payment method required. - Python with the
exa-pySDK (pip install exa-py) or Node.js withexa-js. - A defined enrichment trigger: an incoming record, event, or query that needs web context attached.
- A downstream consumer for the content: a prompt to an LLM, a feature extractor, or a vector index.
Step-by-step
1. Pick the search type for each pipeline stage
Match retrieval mode to the latency budget of the stage, per Exa's Search quickstart:
lite: about 200 ms, $4 per 1,000 requests. Cache-only, no AI summaries, and it rejectsoutputSchema. Use it for per-request enrichment in online serving paths.auto: about 1 second, $7 per 1,000 requests. The default; supportsoutputSchema, summaries, and freshness controls. Use it for interactive stages that need structured output.deep-liteanddeep: about 4 seconds and 4 to 15 seconds respectively, $12 per 1,000 requests. Use for offline or background enrichment where depth matters more than speed.
2. Search and extract content in one call
The base price includes text and highlights for up to 10 results, billed once. The Python SDK uses snake_case arguments:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
result = exa.search(
"latest approaches to retrieval-augmented generation evaluation",
type="lite",
num_results=5,
contents={"highlights": {"max_characters": 500}},
)
for r in result.results:
print(r.title, r.url, r.highlights)
Per Exa's highlights docs, 500 characters of highlights match the retrieval accuracy of the first 8,000 characters of page text, so highlights are usually the right default for feeding model prompts: relevant passages without the token cost of full pages.
3. Fetch clean content for URLs you already hold
When your pipeline already knows the URL (a page referenced in a ticket, a document link in a record), skip search and call the Contents API at $1 per 1,000 pages per returned content type. It handles JavaScript-rendered pages and PDFs and returns clean text. Note that it does not bypass logins, paywalls, or CAPTCHAs, so gated sources need their own access path.
4. Control freshness explicitly
For enrichment where staleness matters, set maxAgeHours (on /search it lives inside contents; on /contents it is top-level). A value of 0 requires content fetched within the last 60 seconds, -1 uses only the cache, and positive values bound cache age up to 720 hours. Fresh fetches add latency, so reserve maxAgeHours: 0 for stages that genuinely need it. See the Contents reference for details.
5. Handle rate limits and retries
Exa's rate limits allow 10 queries per second on /search (including the Free tier), 5 QPS on the deep types, and 100 QPS on /contents. On a 429, wait for the Retry-After header or back off exponentially. For high-volume backfills on an Enterprise plan, the Batch API is an option instead of pushing everything through the synchronous path; it is in beta, requires the Exa-Beta: batches-2026-06-06 header, and has no documented discount.
6. Ground model outputs in the retrieved pages
If a stage uses an LLM over the enriched content, keep the returned URLs and highlights alongside the model output so each prediction can be traced back to a source. For example, a pipeline enriching company records with regulatory signals can search filings coverage and attach the source URL to each extracted field; the primary documents themselves are independently checkable on SEC EDGAR full-text search, which covers filings submitted electronically since 2001.
Common pitfalls
- Using
autoeverywhere. It costs nearly doubleliteand adds latency. Reserve it for stages that needoutputSchema, summaries, or fresh fetches, whichliterejects with a 400. - Pulling full page text by default. On Exa's SimpleQA evaluation, 500 characters of highlights matched the accuracy of the first 8,000 characters of page text, at a fraction of the tokens. Full text is for stages that genuinely need whole documents.
- Assuming every result has a date.
publishedDateis an estimate returned only when available; do not build features that require it on every record. - Ignoring the cache-only nature of
lite. It never fetches live, so pages without a cached copy are left out when content is requested. If coverage matters more than milliseconds, useauto. - No backoff on 429s. Bursty enrichment jobs that ignore rate limits waste requests and stall pipelines.
Frequently Asked Questions
How do I keep enrichment latency low enough for real-time serving?
Use the lite search type, which returns in about 200 ms, request highlights rather than full text, and run the call in parallel with other per-request work. Save auto (about 1 second) and the deep types for asynchronous or background stages.
What does this cost at scale?
lite is $4 per 1,000 requests and auto is $7 per 1,000, each including 10 results with text and highlights. Extras are results above 10 ($1 per 1,000) and AI page summaries ($1 per 1,000 pages, not on lite). The separate Contents endpoint is $1 per 1,000 pages per returned content type. At 50 enrichments a day, a 30-day month is about 1,500 requests, or roughly $6 on lite.
Can I get structured JSON instead of raw text?
Yes. Use outputSchema with auto or a deep type: the response includes a synthesized output.content with field-level citations in output.grounding, adding about 2 seconds of synthesis. Validate fields downstream, since a schema governs shape, not factual accuracy.
How do I enrich records continuously rather than per request?
For recurring enrichment on a schedule, the Monitors API reruns a configured search as often as hourly (each run may start up to 30 minutes late) at $2 per 1,000 runs, plus $1 per 1,000 results above 10 and $1 per 1,000 pages for AI page summaries, delivering new results to your webhook. An hourly monitor makes 720 runs in a 30-day month, or $1.44 before extras.
Conclusion
Real-time enrichment stops being an infrastructure project when retrieval and extraction are a single API call. Start with lite search plus highlights for your latency-sensitive path, add the Contents API for known URLs, and layer in freshness controls and structured output only where the stage needs them. The Free tier's monthly $10 in credits covers up to 2,500 lite searches, enough to prototype a 50-enrichments-a-day flow for a 30-day month (1,500 searches) before committing budget.