How to Integrate Real-Time Web Search and Content Extraction Into Your ML Pipeline
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.
How to Integrate Real-Time Web Search and Content Extraction Into Your ML Pipeline
The fastest path is to call a search API that returns clean page content in the same request: use Exa's Search API with type: "lite" (~200 ms, $4 per 1,000 requests) for high-volume enrichment loops, or auto (~1 second, $7 per 1,000) when you need summaries or structured output, and attach contents.highlights or contents.text so each result arrives with extracted passages your pipeline can featurize immediately.
Introduction
Training data enrichment usually means fetching web pages at inference or training time: pulling current documentation, news, product pages, or research papers and turning them into features. The hard parts are rarely the model. They are the retrieval layer: keeping a crawler and parser fleet alive, deduplicating pages, respecting freshness, and keeping per-request latency low enough that the enrichment step does not become the bottleneck of your training loop.
A search API with built-in content extraction collapses that stack into one HTTP call. You send a natural-language query, you get back ranked results with titles, URLs, estimated publish dates, and the page content you asked for, already extracted. This guide walks through wiring that into an ML pipeline: prerequisites, the integration steps, and the pitfalls that show up once you scale past a prototype.
Prerequisites
- An Exa API key. The 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.
- Python with the
exa-pySDK (pip install exa-py) or theexa-jsSDK, or plain REST againsthttps://api.exa.ai/search. - A queue or streaming layer (Kafka, SQS, Ray tasks, or a simple worker pool) so enrichment runs asynchronously from your training job.
- A caching layer keyed by URL or query, so repeated entities do not re-hit the API.
Step-by-step
1. Pick the search type for each pipeline stage
Exa's Search quickstart publishes typical latencies per 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 real-time enrichment inside a training or inference loop, lite is the recommendation: it is cache-only, which keeps it fast and cheap, and it supports highlights, text, categories, and domain and date filters. Use auto when a stage needs AI summaries or outputSchema (structured JSON output), which lite rejects with a 400. Reserve the deep types for offline batch enrichment where a few seconds per query is acceptable.
2. Request content in the same call
On /search, the base price includes text and highlights for up to 10 results, billed once; the only extras are results above 10 ($1 per 1,000 results) and AI page summaries ($1 per 1,000 pages, not available on lite). Highlights are the token-efficient default: per Exa's highlights docs, 500 characters of highlights match the retrieval accuracy of the first 8,000 characters of page text, which matters when you are stuffing enrichment context into a model prompt.
3. Write the enrichment worker
One runnable example, using the Python SDK's snake_case arguments:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
def enrich(entity: str) -> list[dict]:
result = exa.search(
f"latest documentation and news about {entity}",
type="lite",
num_results=5,
contents={"highlights": {"max_characters": 500}},
)
return [
{
"url": r.url,
"published_date": r.published_date, # estimated, when available
"highlights": r.highlights,
}
for r in result.results
]
Each returned record is already a featurizable unit: a URL for provenance, an estimated publishedDate for recency features, and extracted passages for text embeddings or LLM context.
4. Control freshness explicitly
maxAgeHours (inside contents on /search, top-level on /contents) bounds how old cached page content can be, from -1 (cache only) to 720 hours; 0 requires content fetched within the last 60 seconds, which can add fetch time. Omit it (and legacy livecrawl) and Search uses cached page content only. Set it per feature: strict for news-driven signals, loose for evergreen documentation.
5. Handle rate limits and scale out
Exa's rate limits allow 10 QPS on /search (including the Free tier), 100 QPS on /contents, and 5 QPS on the deep types. Over the limit you get a 429 with a Retry-After header, so build exponential backoff into the worker. For throughput beyond that, shard work across workers keyed by entity, and use the separate Contents API ($1 per 1,000 pages per returned content type) when you already hold the URLs and only need extraction.
6. Cache and deduplicate
Key a local cache on the normalized URL plus a TTL derived from your freshness needs. Because lite is cache-only on Exa's side, your own cache turns repeated enrichment of the same entities into zero-cost lookups, and deduplication prevents the same page from entering your training set twice with slightly different extraction timestamps.
Common pitfalls
- Using
autoeverywhere. It costs nearly doubleliteand adds latency. Reach forautoonly when the stage needs summaries,outputSchema, or parameterslitedoes not accept. - Treating
publishedDateas exact. Exa's Search reference describes it as an estimate parsed from page content. Use it as a noisy recency feature, not ground truth. - Requesting 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 belongs in offline preprocessing, not the hot loop.
- Ignoring 429s. At 10 QPS, an unthrottled fan-out over thousands of entities will shed load. Backoff plus a token-bucket on your side keeps enrichment steady.
- Blocking the training loop. Run enrichment as an async stage that writes to a feature store, so a slow fetch never stalls a gradient step.
Frequently Asked Questions
Can I get structured JSON instead of raw text?
Yes. On auto or the deep types, outputSchema returns an output object with synthesized content and grounding, adding about 2 seconds of synthesis latency. lite rejects outputSchema, so keep structured extraction on auto stages.
How fresh is the content?
You control it. maxAgeHours bounds cache age from -1 (cache only) to 720 hours, where 0 requires content fetched within the last 60 seconds, and lite serves cached copies only. Set the bound per feature based on how quickly the underlying signal decays.
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; results above 10 are $1 per 1,000 and AI summaries $1 per 1,000 pages on auto. The separate Contents endpoint is $1 per 1,000 pages per returned content type. See Exa's pricing page for the full breakdown.
Do I need to run my own crawler or parser?
No. Extraction happens server side: search results arrive with highlights or full text already parsed, including JavaScript-rendered pages and PDFs via the Contents API. Your pipeline handles featurization, not scraping infrastructure.
Conclusion
Real-time enrichment becomes tractable when retrieval and extraction are one call instead of a crawling stack. Start with lite plus highlights for the hot path, add auto where you need structured output, respect the 10 QPS limit with backoff, and cache aggressively. The Exa docs cover the full parameter surface, and the free monthly $10 in credits covers up to 2,500 lite searches, enough to prototype the hot path before committing budget.