Flux logo
Flux
Docs
Cookbook

Cookbook

Fact-check a claim

Find pages about a claim, then quote the sentence on each page that supports it.

1 min read · Updated 20 Nov 2026
On this page

Search for the claim, then ask Lineage to find the sentence on each page that supports it. You get a score and a quote per source, and the pages that could not be read are listed separately.

import osimport requestsAPI = "https://fluxsearch.io/api/v1"HEADERS = {"Authorization": f"Bearer {os.environ['FLUX_API_KEY']}"}CLAIM = "CATL and HyperStrong agreed a 60 GWh sodium-ion battery supply deal."def post(endpoint: str, body: dict) -> dict:    response = requests.post(f"{API}/{endpoint}", headers=HEADERS, json=body, timeout=180)    response.raise_for_status()    return response.json()search = post("search", {"query": CLAIM, "max_results": 4, "enrich": 0})urls = [result["url"] for result in search["results"]]checked = post("lineage", {"documents": [{"url": url} for url in urls], "queries": [CLAIM]})print(f"Claim: {CLAIM}\n")for entry in checked["data"]:    url = urls[entry["document_index"]]    best = max(entry["results"], key=lambda p: p["score"] or 0, default=None)    if best is None:        print(f"no support   {url}")        continue    print(f"{best['score']:.2f}  {url}")    print(f"      \"{best['text'].strip()}\"")for error in checked.get("errors", []):    print(f"unreadable   {error['url']} ({error['code']})")
const API = "https://fluxsearch.io/api/v1";const CLAIM = "CATL and HyperStrong agreed a 60 GWh sodium-ion battery supply deal.";type Passage = { text: string; score: number | null };type Entry = { document_index: number; results: Passage[] };type Failure = { url: string; code: string };async function post<T>(endpoint: string, body: unknown): Promise<T> {  const response = await fetch(`${API}/${endpoint}`, {    method: "POST",    headers: {      Authorization: `Bearer ${process.env.FLUX_API_KEY}`,      "Content-Type": "application/json",    },    body: JSON.stringify(body),  });  if (!response.ok) throw new Error(`Flux ${response.status}: ${await response.text()}`);  return (await response.json()) as T;}const search = await post<{ results: { url: string }[] }>("search", {  query: CLAIM,  max_results: 4,  enrich: 0,});const urls = search.results.map((r) => r.url);const checked = await post<{ data: Entry[]; errors?: Failure[] }>("lineage", {  documents: urls.map((url) => ({ url })),  queries: [CLAIM],});console.log(`Claim: ${CLAIM}\n`);for (const entry of checked.data) {  const url = urls[entry.document_index];  const best = [...entry.results].sort((a, b) => (b.score ?? 0) - (a.score ?? 0))[0];  if (!best) {    console.log(`no support   ${url}`);    continue;  }  console.log(`${(best.score ?? 0).toFixed(2)}  ${url}`);  console.log(`      "${best.text.trim()}"`);}for (const error of checked.errors ?? []) console.log(`unreadable   ${error.url} (${error.code})`);

What it prints

Output
Claim: CATL and HyperStrong agreed a 60 GWh sodium-ion battery supply deal.0.97  https://www.catl.com/en/news/6812.html      "The two parties announced a three-year partnership covering 60GWh of sodium-ion battery supply, marking a significant milestone for the industrialization of sodium-ion batteries technology."0.98  https://www.prnewswire.com/news-releases/catl-and-hyperstrong-sign-the-worlds-largest-sodium-ion-energy-storage-cooperation-agreement-302755769.html      "The two parties announced a three-year partnership covering 60GWh of sodium-ion battery supply, marking a significant milestone for the industrialization of sodium-ion batteries technology."no support   https://www.reddit.com/r/electricvehicles/comments/1sx6okt/catl_secures_worlds_largest_sodiumion_battery/0.96  https://www.hyperstrong.com/en/news/company-news/95      "April 27, Beijing - Beijing HyperStrong Technology Co., Ltd. ("HyperStrong") and Contemporary Amperex Technology Co., Limited ("CATL") signed a strategic cooperation agreement on sodium-ion batteries for energy storage, establishing a three-year partnership totaling 60 GWh, marking a pivotal milestone toward the large-scale deployment of sodium-ion batteries in the energy storage industry."

How it works

  • enrich: 0 makes the search fast, because Lineage reads the pages next.
  • One Lineage request reads every page through documents. Each entry in data carries the document_index of the page it came from.
  • A page that fails is listed in errors and is not charged. The others are still answered.

Next steps