Skip to main content
Retrieval-augmented generation (RAG) pairs a search retrieval step with an LLM generation step. The Andi API handles retrieval — you pass the results as context to the LLM, which generates answers grounded in real web sources. The flow: a user asks a question, your app searches the web via the Andi API, the results become context for the LLM prompt, and the LLM generates an answer grounded in those results.

Complete example

Using format=context

For simpler RAG setups, use format=context to get results pre-formatted as markdown. This skips the manual formatting step:
format=context is the fastest path to a working RAG pipeline. Use format=json with extracts=true when you need more control over how context is structured.

Pinning deep mode for RAG

The default auto mode adapts effort per query and is the right default for most RAG pipelines. For research-heavy queries, set searchMode=deep to force broader source coverage and spell correction on every call:
Deep mode takes ~2-3 seconds vs ~1 second for fast mode. Pin it when you need guaranteed broad coverage on every call; otherwise auto already applies deeper treatment when a query calls for it.

Tips for better RAG results

  • Use extracts=true to get longer text passages beyond the short desc field
  • Set limit=5 to limit=10 — more results give the LLM more context to draw from, but too many can dilute relevance
  • Include source URLs in the prompt so the LLM can cite them
  • Use includeDomains to restrict to authoritative sources for domain-specific questions
  • Tell the LLM to say “I don’t know” when the search results don’t contain the answer

Next steps

AI agent tool

Define Andi search as a tool for an AI agent.

Research assistant

Multi-query search with result aggregation.

Response format

Response structure and result types.

Deep search

When to use deep vs fast search.