Use cases
Fresh web results for RAG.
A model's knowledge stops at its training date and your vector store only holds what you put in it. A web search at question time fills the gap.
How it works
- 1Search with the user's question
Send it as it is, or have the model rewrite it into a few queries first.
- 2Use the snippets, or fetch the pages
Snippets are often enough for a quick answer. Fetch the top links when you need depth.
- 3Answer with sources
Pass the text to the model with its URLs, so every claim can carry a link.
Build context from the top results
import os, requests
def web_context(question: str, n: int = 8) -> str:
r = requests.get(
"https://plainserp.com/v1/search",
params={"q": question, "num": n},
headers={"Authorization": f"Bearer {os.environ['PLAINSERP_KEY']}"},
timeout=30,
)
r.raise_for_status()
return "\n\n".join(
f"[{hit['position']}] {hit['title']}\n{hit['url']}\n{hit['snippet']}"
for hit in r.json()["results"]
)Why it fits
- Every result has a position, title, URL and snippet, ready to cite.
- The time filter keeps answers about recent events recent.
- Country and language settings give local results for local questions.
Know before you start
- Snippets are a sentence or two. For full passages, fetch the pages yourself.
- Most calls take one to two and a half seconds, which adds to your answer time.
What it costs
An app that answers 10,000 questions a day with one search each
That is 10,000 searches a day at $0.30 per 1,000. Your first 1,000 are free.
$3.00
a day