Grounding chatbots with live data
Stop your assistant from confidently making things up.
Customer support tools, internal copilots, branded AI assistants — anywhere a chatbot answers questions where being wrong damages the brand.
Start with this shape.
Paste, run, ship.
import Anthropic from "@anthropic-ai/sdk";
const claude = new Anthropic();
async function search(q: string) {
const r = await fetch("https://api.siftq.com/v1/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SIFTQ_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ q, scope: "webpage", size: "5", conciseSnippet: true }),
});
const { webpages = [] } = await r.json();
return webpages;
}
export async function answer(userMessage: string) {
const hits = await search(userMessage);
const sources = hits
.map((h: any, i: number) => `[${i + 1}] ${h.title}\n${h.snippet}\nSource: ${h.link}`)
.join("\n\n");
return claude.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
system:
"Answer ONLY from the SOURCES. Cite as [N]. If sources don't contain the answer, say so.",
messages: [
{ role: "user", content: `SOURCES:\n${sources}\n\nQUESTION: ${userMessage}` },
],
});
}- ✓Sub-180ms p50 means end-to-end answer arrives in <1s including LLM
- ✓Per-result `score` lets you filter low-confidence hits before prompting
- ✓EU region for chatbots serving European users
- ✓No surprise bills — each search is a fixed-cost call
Likely questions.
Do I need to retrieve on every message, or only on factual questions?
Only on factual / lookup turns. Use a small classifier (3-line prompt) or a heuristic (does the message contain a "?" + factual keywords?) to skip retrieval for chit-chat.
How do I prevent the bot from making up answers when retrieval fails?
Strict system prompt that lists the source-cited answer as the only allowed format, plus an explicit "If you cannot answer from the sources, say I don't know." instruction. Then verify by removing all sources at test time — the bot should refuse, not invent.
How do I show citations to the user?
Most teams render inline `[1]` `[2]` markers as clickable links to the source URL. Some add a "Sources" footer with full link list. Either works; consistency matters more than format.
Try it on your
real workload.
The free tier covers most prototypes. No credit card.