Ground chatbot answers in live results with a search API for RAG
A search API for RAG gives a model what its training data cannot: what the web says today. Retrieval becomes a query, the top results become sources, and the answer cites them. Support bots, research assistants and agents that answer about releases, prices or news all need that step. The Search API returns results as JSON and reads any of them as Markdown on demand.
A model without retrieval answers from a snapshot and fills the gaps
Every model has a training cutoff. Ask about a release from last week, a price that changed yesterday or a company that pivoted, and it answers confidently from old data or invents a plausible detail. Users only notice when it is wrong, and by then they have stopped trusting the rest.
A vector store grounds answers in documents you already indexed, not in what changed on the web since. Scraping search results for live retrieval means proxies, a parser per results layout and a second scraper for every source page, all before the model writes its first token.
Search first, expand selectively. microlink.search returns ten results for one request, period keeps them recent, and result.markdown() fetches only the sources worth reading, as Markdown that uses fewer tokens than HTML. The model gets fresh, citable context, and you decide how many requests each answer costs.
How to ground LLM answers with real-time search
Retrieve, expand the top sources, and pass them to the model with their URLs so the answer can cite them. The content expansion guide describes the two-step model this follows.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const question = 'What changed in the latest Node.js LTS release?'
const page = await microlink.search('Node.js LTS release notes', {
period: 'month',
limit: 5
})period keeps the results recent and limit caps the page at five. Each result carries title, url and description, often enough to decide what is worth reading.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const sources = await Promise.all(
page.results.slice(0, 3).map(async (result, index) => ({
id: index + 1,
title: result.title,
url: result.url,
content: (await result.markdown()).slice(0, 8000)
}))
)Three expansions are three more requests, four for the whole answer. Truncating each source keeps the prompt inside your context budget.
const context = sources
.map(({ id, title, url, content }) => '[' + id + '] ' + title + ' (' + url + ')\n' + content)
.join('\n\n')
const answer = await llm.generate({
system: 'Answer only from the sources. Cite them as [n].',
prompt: context + '\n\nQuestion: ' + question
})llm.generate stands for your model client. Numbered sources with their URLs let the model cite, and let you render each citation as a link.
- period hour, day, week, month or year. Keeps retrieval recent.
- limit Maximum number of results per page. Fewer results, smaller tool output.
- type Route to 'news' or 'scholar' when the question is about current events or research.
- markdown() Reads one result as Markdown, one request per call.
- markdown true fetches the Markdown of every result up front instead of on demand.
markdown: true is simpler, but it reads every result whether the model needs it or not, so keep it for small limits. The agent tool calling pattern lets the model decide when to search and which sources to read.
Why search plus selective reading is the right shape for LLM grounding
Grounding has two costs: requests and tokens. Splitting retrieval from reading keeps both proportional to what the answer needs.
For questions about papers or current events, route the retrieval to Scholar papers and citations or Google News by country.
Already have the URLs? Turn any URL into LLM context with Markdown, links and metadata in parallel.
When not to: if the answer lives in your own documents, a vector store over them is faster and cheaper than a live search per question. Live search is for what changes on the web, and it adds a network round trip to every grounded answer.
FAQ
How do I use a search API for RAG?
How much does grounding an LLM answer with live search cost?
How fast is real-time search for chatbots?
Should an LLM grounding API return HTML or Markdown?
Is the web search for LLMs affiliated with Google?
Solve the next problem with the same API
Google results page as Markdown or HTML
Brand and media monitoring from Google News
Papers and citation counts from Google Scholar
Keyword research with Google Autocomplete
LLM context from any URL
Clean Markdown, no boilerplate
Ready to ground every answer?
Live search results plus Markdown for the sources worth reading. Get a Pro key and ship your first grounded answer today.