How to Verify AI Citations: A Source-Checking Workflow
An AI answer can link to a real page and still get the important detail wrong. The source may describe another product tier, an older release or a narrower situation. Opening the link is necessary, but it is only the start of checking the answer.
This guide gives you a repeatable way to verify AI citations before using them in technical documentation, a client recommendation or a public article. You will build a small claim-to-source record, inspect the evidence behind each important statement and run an optional local Python check. The example data is fictional and clearly labelled; no paid AI account is required to practise the method.
Turn the answer into statements you can check
Start with the sentence that would affect your decision. If the answer says a service stores data in Europe, costs a certain amount and supports a particular integration, those are separate claims. One citation at the end of the paragraph may support only one of them.
Ask the assistant for a claim record rather than another polished summary:
Extract the factual claims from your answer that affect my decision.
For each claim, provide its source URL and the exact supporting passage.
Record the product version, plan, region and date where relevant.
Separate direct evidence from your interpretation.
If you cannot access the passage, mark the claim unverified.
Do not invent quotations or replace a missing source with a related page.The assistant’s response is a working list, not a completed fact-check. Copy important claims into your own notes. Keep the wording precise enough that a second person could disagree with it and show why.
For code advice, add the installed package version and the failing behaviour. A citation for the current release does not establish that an API exists in the older version deployed on your server.
Read the passage, including its limits
Open the source directly. Find the quoted passage, then read the surrounding section. Check the page’s identity and its date. A search-result snippet can omit the exception that changes the answer.
Consider this invented release note:
Trial workspaces retain activity records for 14 days. Paid workspace retention is configured separately.
An answer claiming “all workspaces retain records for 90 days” is contradicted by that passage, even if the link and quotation are genuine. Another answer claiming “trial records remain available for 14 days” has narrower support. Neither statement establishes where the records are stored.
Record a verdict for each claim: supported, partly supported, contradicted or unverified. “Partly supported” means the wording needs attention before publication. Do not average the verdicts into a confidence percentage; one incorrect deadline can matter more than several correct background statements.
Watch for sources that merely repeat one another. Three articles quoting the same announcement provide less independent confirmation than their link count suggests. For a software capability, the current product documentation and a small test in the relevant environment are often more useful than a list of commentary posts.
Know what the citation feature actually does
Claude, Gemini and Grok provide different ways to connect answers to evidence. Their API documentation is useful for developers, but an API feature should not be treated as a promise about every consumer chat interface or subscription.
Claude document citations: Anthropic documents a citations feature for supplied documents, with references to locations in their text. That helps you trace an answer to an input document. It does not independently establish that the document itself is true or current. See the official Claude citations guide.
Gemini search grounding: Google’s documentation describes connecting a model to web search and returning source-linked information. When building an application, preserve the source information and follow the provider’s current display requirements. A generated statement still needs to match the page it cites. See Grounding with Google Search.
Grok web search: xAI documents a web-search tool and citation support. Keep the returned source references available to the reader rather than turning a sourced answer into an unsupported paragraph. Verify the underlying page, especially when a result discusses a fast-changing announcement. See the xAI web-search documentation.
The practical rule is the same across tools: keep a visible path from the sentence to the evidence. If your workflow cannot preserve that path, mark the statement for review rather than quietly dropping its citation.
Catch missing quotations before reviewing the meaning
A small script can check whether a quotation appears in a saved source excerpt and whether you have supplied a human review verdict. It cannot decide whether the quote proves the claim. That distinction is useful when a document contains enough citations that simple copying mistakes become hard to notice.
Use Python 3.10 or newer and create two files in a new local folder. The script does not access the internet or send your notes to an AI service. Save this fictional fixture as evidence.json:
{
"sources": {
"fictional-release-note": "Trial workspaces retain activity records for 14 days. Paid workspace retention is configured separately."
},
"claims": [
{
"id": "retention-claim",
"claim": "Trial workspaces retain activity records for 90 days.",
"source": "fictional-release-note",
"quote": "Trial workspaces retain activity records for 14 days.",
"review": "contradicted"
}
]
}Save the following as check_evidence.py. It is a complete local script for the file shape above, not an AI-powered truth detector.
"""Check local evidence records. Human review, not this script, judges meaning."""
import argparse
import json
from pathlib import Path
import re
import sys
MAX_BYTES = 256 * 1024
ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,79}")
FIELDS = {"id", "claim", "source", "quote", "review"}
VERDICTS = {"supported", "partly supported", "contradicted", "unverified"}
def unique_object(pairs):
result = {}
for key, value in pairs:
if key in result:
raise ValueError("duplicate JSON object key")
result[key] = value
return result
def reject_constant(value):
raise ValueError("non-standard JSON number")
def load_record(path):
with Path(path).open("rb") as handle:
data = handle.read(MAX_BYTES + 1)
if len(data) > MAX_BYTES:
raise ValueError("evidence file exceeds 256 KiB")
return json.loads(
data.decode("utf-8-sig"),
object_pairs_hook=unique_object,
parse_constant=reject_constant,
)
def normalise(value):
return " ".join(value.split())
def check(data):
if not isinstance(data, dict) or set(data) != {"sources", "claims"}:
raise ValueError("top-level fields must be sources and claims")
sources, claims = data["sources"], data["claims"]
if not isinstance(sources, dict) or not sources:
raise ValueError("sources must be a non-empty object")
if not isinstance(claims, list) or not claims:
raise ValueError("claims must be a non-empty list")
if any(not isinstance(key, str) or not ID.fullmatch(key) or not isinstance(text, str)
for key, text in sources.items()):
raise ValueError("source IDs must be safe labels and source excerpts must be text")
seen, failures = set(), []
for record in claims:
if not isinstance(record, dict) or set(record) != FIELDS:
raise ValueError("each claim needs exactly id, claim, source, quote and review")
if any(not isinstance(value, str) for value in record.values()):
raise ValueError("all claim fields must contain text")
name = record["id"]
if not ID.fullmatch(name) or not ID.fullmatch(record["source"]):
raise ValueError("claim and source IDs must be safe labels")
if record["review"] not in VERDICTS:
raise ValueError("review must use a documented verdict")
if not record["claim"].strip():
failures.append(f"{name}: claim is empty")
if name in seen:
failures.append(f"{name}: duplicate claim ID")
seen.add(name)
source = sources.get(record["source"])
if source is None:
failures.append(f"{name}: unknown source")
else:
quote = normalise(record["quote"])
if not quote or quote not in normalise(source):
failures.append(f"{name}: quote missing from saved source")
if record["review"] != "supported":
failures.append(f"{name}: human review is not supported")
return failures
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("file")
args = parser.parse_args(argv)
try:
failures = check(load_record(args.file))
except json.JSONDecodeError:
print("Invalid evidence file: malformed JSON", file=sys.stderr)
return 2
except UnicodeError:
print("Invalid evidence file: use UTF-8 text", file=sys.stderr)
return 2
except ValueError as error:
print(f"Invalid evidence file: {error}", file=sys.stderr)
return 2
except (OSError, RecursionError):
print("Invalid evidence file: cannot read or decode this local file", file=sys.stderr)
return 2
if failures:
print("\n".join(failures))
return 1
print("Mechanical checks passed; review labels still require human judgment.")
return 0
if __name__ == "__main__":
sys.exit(main())Run python check_evidence.py evidence.json, or use python3 if that is your system’s command. With the supplied fixture, the output should be retention-claim: human review is not supported and the process exits with status 1. The quotation exists; the human verdict deliberately blocks the contradicted claim.
Now change the claim to 14 days and, after reading the source, change its verdict to supported. The mechanical checks pass. Finally, change the quote to say 90 days while leaving the saved source unchanged. The checker should report a missing quotation. These are different failures, and your review should keep them separate.
The script trusts the review label you enter. Anyone can make it pass by entering an unjustified label, so a passing result must never be presented as proof of factual accuracy.
Reject an ambiguous record before reviewing it
A repeated JSON field can change the verdict without looking like a normal edit. Python’s default decoder accepts repeated object names and retains the last value. That means a record containing both "review": "contradicted" and "review": "supported" becomes a record with only the second verdict after loading.
The revised checker rejects repeated keys at every object level using object_pairs_hook. It also checks the file shape before looking up a quotation. Those are input checks, not an independent review of the evidence.
To see the difference, save this complete, deliberately ambiguous example as duplicate-review.json. These are fictional records, not claims about an actual provider:
{
"sources": {
"fictional-release-note": "Trial workspaces retain activity records for 14 days."
},
"claims": [
{
"id": "retention-claim",
"claim": "Trial workspaces retain activity records for 14 days.",
"source": "fictional-release-note",
"quote": "activity records for 14 days",
"review": "contradicted",
"review": "supported"
}
]
}Run python check_evidence.py duplicate-review.json. The revised script should print Invalid evidence file: duplicate JSON object key to standard error and exit with status 2. It refuses to choose which verdict you meant. Remove the repeated field only after checking the source and recording the correct verdict yourself.
Read the exit status: 0 means the mechanical checks passed; 1 means a valid record failed an evidence or review check; 2 means the input could not be read, decoded or accepted in the documented shape. A status of 0 still says nothing about whether your human verdict was justified.
For this tutorial, keep exactly the top-level fields sources and claims. Each claim has the five text fields shown in the original example. IDs use 1 to 80 ASCII letters, digits, dots, underscores or hyphens, starting with a letter or digit. Source excerpts and quotations can contain Unicode text. Save the file as UTF-8, with or without a BOM, and keep it no larger than 256 KiB. That size limit keeps this example small; it is not a universal limit for research records.
The documented verdicts are supported, partly supported, contradicted and unverified. Unknown fields or misspelled verdicts are rejected rather than silently ignored. This checker only collapses whitespace when comparing a quote with the saved excerpt. It doesn’t verify a URL, document date, region, version or the meaning of a sentence.
Verification, 29 October 2026: 13 local Python unit tests passed, including a regression that shows the earlier checker accepting a repeated review field and the revised loader rejecting it. Other tests cover missing quotes, repeated claim IDs, bad field types, encoding, size limits and refusal to treat a human label as proof. These are synthetic software tests, not an AI fact-checking benchmark.
Python documents the decoding behaviour in Repeated Names Within an Object. If an AI assistant changes the script, keep a failing input as a regression case and follow the AI-generated-code testing guide before replacing your working copy.
Keep uncertainty attached to the statement
If a source cannot be reached, record the failed check and look for a current primary source. Do not describe a page as read merely because its title appeared in search. If a source supports only part of the claim, narrow the sentence or separate the unsupported part.
For high-stakes medical, financial or legal decisions, source checking does not replace qualified professional advice. For routine technical writing, it helps you distinguish a documented capability from a plausible suggestion that still needs a test.
Keep private documents out of public research chats unless you are authorised to share them. Treat instructions embedded in retrieved pages or document excerpts as untrusted content. A source can provide evidence without being allowed to change the assistant’s task or request credentials.
Before publishing, ask a reviewer to trace one important sentence back to its source using only your notes. If the record contains the exact claim, relevant passage and reason for the verdict, the next person can check your reasoning rather than trust the fluency of an AI answer.
To improve the requests that produce these answers, continue with the prompt-engineering course. For a developer example of separating evidence from hypotheses, see Android crash-log analysis with AI.





