How to Integrate Up-to-Date Web Content Into Your ML Pipeline With Low Latency and Relevance Filtering
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 Up-to-Date Web Content Into Your ML Pipeline With Low Latency and Relevance Filtering
The efficient path is to treat web retrieval as a single API call inside your pipeline rather than a crawling subsystem you maintain: use Exa's Search API with the lite type (~200 ms typical latency, $4 per 1,000 requests) for latency-sensitive steps, request highlights instead of full pages to keep tokens down, and filter for relevance at query time with domain, date, and category controls so your model only sees passages that answer the task.
Introduction
An ML pipeline that needs live web content can fail in one of two ways. Either retrieval is too slow to sit in the request path, so the pipeline caches aggressively and serve stale data, or retrieval returns enough raw pages that the downstream model spends its context window on navigation menus and boilerplate instead of signal. Both problems are architectural, not tuning problems: they come from treating retrieval as "fetch everything, filter later."
The fix is to push latency and relevance decisions into the retrieval layer itself. Exa's Search API is built for this pattern: you choose a latency tier per request, you get ranked results with extracted, query-relevant passages in the same call, and you constrain results with parameters rather than post-processing code. This guide walks through the integration step by step, with the parameters and tradeoffs that matter in production.
Prerequisites
- A working Python (3.9+) or JavaScript environment for your pipeline.
- An Exa API key, stored in an environment variable. 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.
- The Python SDK:
pip install exa-py. - A clear sense of which pipeline stages are latency-sensitive (inline retrieval during inference) versus batch (corpus building, scheduled refresh), because the right search type differs between them.
Step-by-step
1. Pick the search type that matches each stage's latency budget
Exa's Search quickstart publishes typical latencies 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. Use lite ($4 per 1,000 requests) for inline, latency-sensitive steps and auto ($7 per 1,000) as the default elsewhere. Reserve the Deep Search types ($12 per 1,000) for stages that genuinely need multi-step synthesis, such as building a research brief, not for every request. Pricing is on Exa's pricing page.
2. Make one retrieval call that returns passages, not pages
Request highlights so each result carries only the passage relevant to your query, with the source URL attached. Exa's highlights docs report that 500 characters of highlights match the retrieval accuracy of the first 8,000 characters of page text, which is what keeps your context window and your inference bill small. The base /search price includes text and highlights for up to 10 results, billed once; results above 10 cost $1 per 1,000, and AI page summaries are $1 per 1,000 pages (lite does not support summaries).
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
result = exa.search(
"transformer inference latency optimization techniques",
type="lite",
num_results=5,
contents={"highlights": True},
)
for r in result.results:
print(r.url)
print(r.highlights[0][:300])
3. Filter for relevance at query time, not in post-processing
The Search reference documents the controls that replace most of your hand-written filtering code:
includeDomainsandexcludeDomainsrestrict results to sources you trust, including path prefixes such asexample.com/docs.startPublishedDateandendPublishedDatebound results to a date window, useful when your model should only see recent material.categoryselects category-specific retrieval for a data type, such as news, research publications, or company information.maxAgeHours(onautoand the Deep types;literejects it) caps how old cached page content can be, from -1 to 720 hours. Setting it to0requires content fetched within the last 60 seconds, which can add fetch time to the request.
4. Handle freshness explicitly
When both maxAgeHours and legacy livecrawl are omitted, Search uses cached page content only. If your pipeline needs recently changed pages, set a low maxAgeHours on auto and accept the extra fetch latency, or run retrieval in a batch stage where a fresh fetch costs nothing user-facing. Do not assume results reflect everything published as of the request; check publishedDate on results when it is returned.
5. Keep recurring updates out of the request path
If your pipeline needs the same query refreshed on a schedule (a monitoring feed that feeds a training or alerting job), the Monitors API reruns a configured search on a schedule as often as hourly, with each run possibly starting 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. Each run removes results the monitor has already returned, so downstream jobs only process new material. This keeps scheduled retrieval off your latency-sensitive path entirely.
6. Set rate limits and retries deliberately
Check the published rate limits before load testing, and add retries with backoff around the search call so a transient failure degrades to cached or empty context rather than failing inference. At lite's ~200 ms typical latency, one retrieval call usually fits comfortably inside an inference budget that also includes model time.
Common pitfalls
- Using a deep search type everywhere.
deep(4 to 15 seconds) is for synthesis-heavy stages. Putting it in the inline path adds seconds to every request. - Fetching full pages by default. Full-page text burns context and money. Highlights give you the relevant passage; Exa's evaluations put 500 characters of highlights on par with 8,000 characters of raw page text.
- Filtering in Python instead of in the query. Post-fetch keyword filters are brittle and slow. Domain, date, and category parameters do the work at retrieval time.
- Assuming
outputSchemaworks everywhere. Structured output viaoutputSchemaworks withautoand the Deep types and adds about 2 seconds of synthesis;literejects it with a 400 error. - Treating cached content as live. Without a freshness parameter, results can come from cached copies. Set
maxAgeHours(on non-litetypes) when recency matters, and budget for the fresh fetch.
Frequently Asked Questions
How do I keep retrieval under a second in an inference loop?
Use the lite search type, which returns in about 200 ms at $4 per 1,000 requests, request highlights instead of full text, and keep num_results at or near the 10 included in the base price. Exa's Search quickstart lists the per-type latency figures.
How do I restrict results to sources my pipeline can trust?
Set includeDomains (with path prefixes if needed), excludeDomains, and a category on the search call, and bound recency with startPublishedDate. These are documented in the Search reference and replace most post-fetch filtering.
What does this cost at realistic volume?
Prices attach to the product and type: lite is $4 per 1,000 requests, auto is $7, the Deep types are $12, and Monitors is $2 per 1,000 runs (an hourly monitor makes 720 runs, or $1.44, in a 30-day month before extras), per Exa's pricing page. For example, 50 lite searches a day is 1,500 requests over a 30-day month, or $6 before any extras such as results above 10 or AI summaries.
How do I get fresh content without slowing every request?
Split the work: keep lite in the inline path, and use maxAgeHours: 0 on auto for stages that need content fetched within the last 60 seconds, or schedule recurring retrieval with Monitors so updates arrive as often as hourly without touching your request path.
Conclusion
Low-latency, relevant web retrieval is mostly a matter of putting the right controls in the retrieval call: a latency tier matched to each pipeline stage, highlights instead of full pages, and query-time filters for domains, dates, and categories. Exa's Search API gives you all three in one endpoint, with published latency and pricing figures you can plan against, and Monitors handles the scheduled-refresh case off the critical path. Start with one lite search call wired into your most latency-sensitive stage, measure it against your own budget, and expand from there.