Skip to content
Search API · Use case

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.

The problem

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 it works

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.

1 · Retrieve recent results
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.

2 · Expand the top sources as Markdown
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.

3 · Answer with citations
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.

Parameters used
  • 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 it works

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.

01 · Predictable cost
One request to search, one per source read.
Ten results cost one request. Reading three of them costs three more. The budget per answer is a number you choose, not a side effect of how many links a page happened to have.

For questions about papers or current events, route the retrieval to Scholar papers and citations or Google News by country.

02 · Fewer tokens
Markdown instead of HTML for every source.
markdown() returns each source as Markdown, which uses fewer tokens than HTML for the same content and keeps the headings, lists and tables a model can follow.

Already have the URLs? Turn any URL into LLM context with Markdown, links and metadata in parallel.

03 · The model decides
Expose search and read as two tools.
Give an agent a search tool that returns title, url and description, and a read tool that returns Markdown. The model searches, reads the sources it trusts, and asks for the next page only when the first was not enough.

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?

Search the question with microlink.search, expand the top results with result.markdown(), and pass the Markdown to the model with each source’s URL. Restrict freshness with period and cap the page with limit so every answer has a known cost.

How much does grounding an LLM answer with live search cost?

One request for the search and one per result you expand, so search plus three sources is four requests per answer. Search has no free tier: Pro plans start at €39/month for 46,000 requests with a 99.9% SLA.

How fast is real-time search for chatbots?

Search results arrive in about a second. Reading a source fetches a full page, which is slower than the search itself, so expand sources in parallel and only the ones the answer needs.

Should an LLM grounding API return HTML or Markdown?

Markdown for the model: it uses fewer tokens than HTML for the same content. Call result.html() when your own code needs the DOM, for example to parse a table with selectors before handing the data to the model.

Is the web search for LLMs affiliated with Google?

No. Microlink Search is an independent product that queries public Google surfaces. It is not affiliated with or endorsed by Google, and Google is a trademark of Google LLC.
Related use cases

Solve the next problem with the same API

Google results page as Markdown or HTML

Start from a query, not a URL: get the structured results plus the Google results page itself as Markdown or HTML.

Brand and media monitoring from Google News

Query Google News by brand, country and time window and get headline, publisher and ISO 8601 date for every article.

Papers and citation counts from Google Scholar

Collect papers with year, citation count and PDF link from Google Scholar, merge queries by ID and read the shortlist as Markdown.

Keyword research with Google Autocomplete

Expand a seed into the queries people type, plus related searches and People Also Ask questions, per country.

LLM context from any URL

Compose Markdown, links, emails, metadata and tech stack from one URL into a context object for your agent.

Clean Markdown, no boilerplate

Convert only the article body: one selector keeps navigation, ads and widgets out of the Markdown.

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.