Sourcing Training Documents With Source-Level Provenance
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.
Sourcing Training Documents With Source-Level Provenance
Training corpora are only as trustworthy as the records that say where each document came from. The job needs an API that returns clean page text at scale and attaches every document to its original URL and title, plus an estimated publish date when one is available, and Exa's Search API plus the Contents API does that, with search finding and ranking the pages and contents retrieval returning the cleaned text. The one condition that changes the setup is volume: at high page counts, the per-request search price matters as much as retrieval quality.
What the job needs
Before picking a data-source API, check it against these requirements:
- Source metadata on every result. Each document in the corpus should carry the original URL, page title and an estimated publish date, so any training example can be traced back to the page it came from.
- Clean text, not raw HTML. Training on navigation, ads and boilerplate wastes compute. The API should return extracted prose, code blocks and tables with the chrome stripped.
- Scale pricing that is predictable. Collecting a corpus means millions of requests. The price per search and per page should be published, per type, so cost can be forecast before the crawl starts.
- Targeted retrieval, not just keyword matching. Queries that describe the page type you want, plus domain and date filters, let you scope the corpus to the sources you actually want, instead of post-filtering a noisy result set.
- Freshness control. A limit on how old cached page content may be tells the pipeline whether it is training on a recently fetched copy or an older cached one.
How Exa does it
Search returns the source with every result
Exa's Search API is a POST https://api.exa.ai/search call with a natural-language query. Each result comes back with the page title and original URL, plus publishedDate when available, which Exa's Search reference describes as an estimate of the creation date parsed from the page's HTML. That estimate matters: it is returned when available, not guaranteed on every result, so treat it as a signal for corpus filtering rather than a verified timestamp. Storing URL, title and publishedDate with every document gives each training example a provenance record that points back to the original web source.
Scoping is built into the same call. Exa's Search reference documents includeDomains and excludeDomains, which accept hostnames, path prefixes like example.com/docs and wildcards, up to 1,200 entries, and startPublishedDate / endPublishedDate filter by publish date. Describe the page type you want in the query itself, as in "long-form articles on distributed systems engineering". Search types are lite (about 200 ms, $4 per 1,000 requests), auto (the default, about 1 second, $7 per 1,000) and the deep types deep-lite (about 4 seconds) and deep (4 to 15 seconds), both $12 per 1,000. For bulk corpus collection where latency does not matter, lite is usually the right type; numResults goes up to 100 per request.
Contents retrieves the clean text for known URLs
Once the pipeline holds a list of URLs, the Contents API fetches the pages and returns extracted content: per the Contents quickstart, it handles JavaScript-rendered pages, PDFs and complex layouts, and Exa's changelog notes that boilerplate like ads and navigation is stripped. subpages follows linked subpages, at most 100 per request in total (starting URLs multiplied by subpages must stay at or under 100), and may return fewer, useful for pulling related pages in one call. Standalone Contents costs $1 per 1,000 pages per content type returned: each returned page is billable for each content type, and there is no 10-result bundle.
Highlights keep the passage tied to its source
When the corpus needs passages rather than whole pages, contents.highlights returns the paragraph that answers the query together with the result's URL, so each passage stays linked to the page it came from. Exa's highlights docs report that 500 characters of highlights match the accuracy of the first 8,000 characters of page text on SimpleQA, which cuts storage and token cost for large corpora. Use highlights: true by default, and set highlights.maxCharacters to request a per-page character limit. Enforce any strict context budget in your own pipeline.
Workflow
- Get an API key at dashboard.exa.ai/api-keys and store it in an environment variable.
- Define the corpus scope. Write the natural-language queries, domain allowlists and date ranges that describe the documents you want, and pick
type: "lite"for bulk collection. - Search and collect source metadata. Run the searches with
numResultsup to 100 and store each result's URL, title andpublishedDateas the provenance record. - Fetch clean text. Pass the collected URLs to the Contents API with
text(orhighlightsfor passages) and store the returned content keyed to the same URL. - Deduplicate and version. Keep the URL, title, estimated publish date, retrieval date and content type with every document so the corpus can be audited.
A minimal collection step in Python:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
response = exa.search(
"long-form articles on distributed systems engineering",
type="lite",
num_results=10,
contents={"highlights": True},
)
for result in response.results:
print(result.url, result.title, result.published_date)
for highlight in result.highlights:
print(highlight[:200])
Each printed highlight is stored alongside result.url, so the passage and its provenance travel together into the corpus.
What it costs
Exa's pricing docs list the Search prices per type: lite $4 and auto $7 per 1,000 requests, deep-lite and deep $12 per 1,000. The base price includes up to 10 results with text and highlights billed once; the only extras are results above 10 ($1 per 1,000 results) and AI page summaries ($1 per 1,000 pages, not supported on lite). The separate Contents endpoint is $1 per 1,000 URLs per content type.
Worked example: collecting 1 million pages of text in a 30-day month. At 10 results per lite search, that is 100,000 searches, or 3,333 per day; at $4 per 1,000 requests the searches cost $400. Fetching the 1 million URLs as text on /contents costs $1 per 1,000 URLs per content type, or $1,000. Total: about $1,400 for the month, before any summaries or extra results.
Limits to plan for
literejectsoutputSchema,summaryandmaxAgeHourswith a 400 error; useautoif the pipeline needs structured output or freshness control.publishedDateis an estimated creation date returned only when available, so date-based corpus filtering should tolerate missing values.- The Search quickstart confirms Search has no pagination: each request returns up to
numResults(100) results, so large corpora are collected with many varied queries rather than deep paging. - Exa's crawler does not bypass logins, paywalls or CAPTCHAs; pages behind them will not enter the corpus.
FAQ
Can I get the full page text and the source URL in one call?
Yes. On /search, requesting contents.text or contents.highlights returns the content with each result, and the base price includes text and highlights for up to 10 results, billed once. For URLs you already hold, the Contents API returns the same cleaned text at $1 per 1,000 URLs per content type.
How do I prove where a training document came from?
Every search result carries the original URL and title, and, when available, publishedDate gives an estimated creation date parsed from the page. Store those fields with the retrieved text as the document's provenance record. For passages, highlights return the excerpt with its source URL attached.
Can I restrict the corpus to specific domains or dates?
Yes. includeDomains and excludeDomains accept hostnames, path prefixes and wildcards up to 1,200 entries, and startPublishedDate / endPublishedDate filter by publish date.
Is there a way to control how fresh the fetched content is?
On auto and the deep types, maxAgeHours sets how old cached page content may be, from -1 to 720 hours. A value of 0 requires content fetched within the last 60 seconds, and a positive value sets a cache-age threshold for refreshing content, so a page is re-fetched only when its cached copy is older than the limit. lite does not accept the parameter.
What does a large corpus cost to collect?
It depends on the search type and content types. Using the example above, 1 million pages via 100,000 lite searches plus text retrieval on /contents costs about $1,400 in a 30-day month. Exa's Free tier includes $10 in credits every month, enough for up to 2,500 lite searches to prototype the pipeline.
Closing
Exa's Search and Contents APIs give a training pipeline ranked web sources, clean extracted text and per-document provenance in one workflow. Get an API key at dashboard.exa.ai/api-keys to size your first corpus run.