Where web search belongs in retrieval-augmented generation

Retrieval-augmented generation gives a language model relevant external information before it produces an answer. That information can come from an internal document index, a database, a search API or a combination of sources.

Use internal retrieval for authorized company information, such as support policies or private product documentation. Use web discovery when the question needs current public sources or material outside the index. A question about a customer's private contract should not be turned into a public web query containing the contract details.

The phrase “search API” covers several products. Google's search and RAG API overview, for example, describes APIs for building retrieval experiences. A Google SERP API has a narrower role: discovering and observing public search results. Decide which role is missing from your architecture before choosing a service.

A practical web-search RAG pipeline

User question
  -> decide whether fresh external evidence is needed
  -> search for relevant source URLs
  -> select and retrieve allowed pages
  -> extract passages and retain source information
  -> rank passages for the question
  -> generate a source-supported answer
  -> check claims and report evidence gaps

This is an application design, not an OrbitScraper endpoint sequence. OrbitScraper can provide the Google search discovery step. Page retrieval, extraction, reranking and answer generation are separate responsibilities unless you choose additional services that perform them.

For example, a developer asks whether a library's latest release changed an authentication option. The system searches for official release notes and documentation, retrieves the relevant pages and selects passages about that option. It should preserve the version context rather than blend an old tutorial with the current reference.

Step 1: decide when the web is needed

Route questions based on their information needs. A stable definition may be answerable from a maintained internal source. A question about current pricing or a recent release needs fresh evidence. A question mixing private and public information may require both, while keeping private details out of the search query.

Make the query specific enough to locate useful sources. Include the product, version or subject where relevant. Prefer a small number of purposeful searches to repeated broad searches that produce the same links.

Set a limit before starting. A research assistant might allow a few searches and several page reads, then return the supported findings and remaining gaps. The right budget depends on the task, but it should be deliberate.

Step 2: choose sources before adding them to context

Search snippets are good discovery aids, but they may omit qualifications, dates or surrounding explanations. For detailed claims, retrieve the page and read the relevant passage.

Prefer primary sources for product specifications and policy statements. Check that the page concerns the correct product, version and market. Deduplicate repeated URLs so a source appearing through several queries does not crowd out other evidence.

Be careful with freshness. The date your application fetched a page is not necessarily the date its facts changed. Preserve any reliable publication or update information and explain uncertainty when the source does not provide it.

For a comparison, use the official feature or pricing page for each provider. A search-result summary of somebody else's comparison is a lead to investigate, not proof of the underlying price.

Step 3: retain provenance with every passage

Keep a source identifier, original URL, retrieved text and retrieval time together. If passages are shortened or reranked, keep that connection intact. Otherwise, the final answer may cite a page that was found during search but never supported the claim.

The following record is an illustrative application format:

{
  "source_id": "S1",
  "url": "https://example.com/releases/version-3",
  "retrieved_at": "2026-11-28T10:00:00Z",
  "title": "Version 3 release notes",
  "passage": "The selected source passage goes here.",
  "version_context": "Version 3"
}

A compact record is often more useful than dumping an entire page into a prompt. Keep enough surrounding text to preserve meaning, though: removing the sentence containing an exception can reverse the interpretation of the passage.

Step 4: generate answers that stay within the evidence

Ask the model to support factual claims with the supplied source identifiers and to distinguish an unanswered question from a negative answer. If the evidence does not establish whether a feature exists, the answer should say that it could not confirm the feature.

The following Python helper is a small, executable citation check for an application's own records. It verifies that referenced IDs exist; it does not determine whether the cited passages truly support the answer.

def unknown_citations(answer_source_ids, evidence):
    available = {item["source_id"] for item in evidence}
    return sorted(set(answer_source_ids) - available)

evidence = [{"source_id": "S1", "url": "https://example.com/guide"}]
print(unknown_citations(["S1", "S2"], evidence))  # ['S2']

Add a separate support check for important claims. Does the passage actually state the price, limitation or instruction? Does it concern the right version? A valid URL and a plausible citation marker are not sufficient by themselves.

Evaluate failures at the right stage

FailureLikely stage to investigateUseful response
Relevant source was never foundQuery or discoveryRefine the query or source selection
Correct page, irrelevant passageExtraction or rankingImprove passage selection and context
Good passage, unsupported conclusionAnswer generationTighten claim support and uncertainty handling
Citation points to missing evidenceProvenancePreserve and validate source identifiers
Answer uses outdated informationFreshness reviewCheck source dates and refresh criteria

Build an evaluation set with recent changes, ambiguous product names, version conflicts and questions with no reliable answer. Review factual correctness and citation support alongside latency and cost. A system that appropriately explains missing evidence is often more useful than one that always produces a confident paragraph.

Treat retrieved pages as untrusted content. Their instructions must not override the application's permissions or reveal secrets. Apply appropriate access controls to page retrieval, including restrictions on private network destinations when your application fetches arbitrary URLs.

Choose the search layer for your actual evidence needs

OrbitScraper is useful when you want structured Google desktop results and source links as the discovery input. Optional Markdown can simplify the search context passed to a model, while structured data helps the application filter results. The agent search guide compares that role with services offering additional content or answer capabilities.

If your assistant supports MCP, the Google Search MCP guide provides a connection path. If you control the application directly, follow the API documentation. Neither integration removes the need to retrieve and assess evidence for detailed answers.

Start with one recurring question type, a small evidence budget and an explicit definition of a good answer. Try OrbitScraper for the discovery step, then evaluate whether the complete pipeline produces useful, traceable answers for that task.

Frequently Asked Questions

Is a search API the same as a vector database?

No. A search API discovers or retrieves results from its search source. A vector database supports similarity retrieval over indexed representations. A RAG application can use either or combine them, depending on where the needed information lives.

Can I build web-search RAG without a vector database?

Yes. A small workflow can search, retrieve a few pages and select passages directly. An index becomes useful when you need repeated retrieval over a managed collection, but it is not a prerequisite for every web-search task.

Does RAG eliminate hallucinations?

No. Retrieval can provide evidence, but the model can still misinterpret it or make unsupported claims. Check the relationship between important claims and their cited passages, and allow the system to report missing evidence.

Should I send full web pages to the model?

Not automatically. Select relevant passages with enough context to preserve meaning and keep their source information. Sending more text can increase cost and introduce irrelevant material without improving the answer.

How should I cache search results for RAG?

Choose a freshness policy based on the question. Stable documentation and changing prices have different needs. Keep retrieval timestamps and source context, and refresh when the task requires newer evidence rather than applying one universal cache lifetime.

Start Building with OrbitScraper

Test a small set of queries that represents your workflow, then review the returned fields and credit usage before expanding collection.

Use the API documentation to plan your integration and the current pricing page to check the terms for your expected workload.