Citation verifier
citation-verifier compares a model answer with the source text that your application sends in the request, and can block an answer that is not grounded in it. It also finds citations in the answer, such as quotes, DOIs, and URLs, and can look some of them up.
It is not a fact checker. It measures word overlap: an incorrect claim can overlap well, and a correct paraphrase can score low.
It runs on Chat Completions, Responses, and Messages. With streaming, the gateway holds the output until the complete-response checks finish.
Configuration
This configuration checks the answer against the supplied context only, without external lookups. Apply it to a test gateway with the config-first workflow.
pack:
name: citation-verifier-example
version: 1.0.0
enabled: true
policies:
chain:
- citation-verifier
policy:
citation-verifier:
require_sources: true
require_source_match: true
min_confidence: 0.8
min_groundedness: 0.8
extract_patterns:
- quote
rag_context:
verify_against_context: true
min_context_overlap: 0.7
output_action:
unverified_action: block
response:
include_verification_report: trueFields
| Field | Type | Default | Description |
|---|---|---|---|
require_sources | boolean | true | The answer must contain source evidence |
require_source_match | boolean | true | With require_sources, a citation alone is not enough: a quote must match the context, the overlap must reach min_context_overlap, or an external lookup must succeed. |
min_confidence | number | 0.8 | Minimum share of claims whose overlap reaches min_groundedness |
min_groundedness | number | 0.8 | Minimum word overlap of one claim. Also the fallback for rag_context.min_context_overlap. |
extract_patterns | string[] | case_law, academic, url, quote, statistic, regulatory | Citation types to find. academic enables DOI and PubMed lookups; URL lookups also require VERDICTAN_CITATION_URL_LOOKUP=1 or true. Lint accepts all six types. |
rag_context.verify_against_context | boolean | true | Compares the answer with the context documents of the request |
rag_context.min_context_overlap | number | 0.7 | Minimum word overlap of the whole answer with the context |
output_action.unverified_action | string | flag | flag, redact, or block. Only block changes the verdict. redact does not change the answer. |
response.include_verification_report | boolean | true | With false, the details contain only verified and groundedness. |
| external_resolver.endpoint | string | | Optional citation resolver URL. Receives case-law and regulatory citations. |
| external_resolver.api_key | string | | Optional literal bearer credential. This field does not accept secret_key_ref or expand environment placeholders. Protect any configuration that contains it. |
| external_resolver.timeout_ms | integer | 2000 | Resolver timeout, from 1 through 60000 milliseconds |
| output_action.hallucination_action | string | block | A confirmed nonexistent citation blocks when this value is block, even if other grounding checks pass. |
Phase and verdicts
| Item | Value |
|---|---|
| Phase | output |
| Enforced path | Chat Completions, Responses, and Messages, including buffered streaming output |
| Verdicts | allow, block |
| Reason codes | citation.verified, citation.unverified, citation.hallucinated |
A block returns HTTP 400 with error code content_policy_violation and a verdictan.decision object with verdict BLOCK.
Supply the text to verify against
Put the source text in verdictan.context_documents of the request. This body gives the same source to the model and to the verifier:
{
"model": "gpt-4o-mini",
"stream": false,
"messages": [
{"role": "system", "content": "Return only this exact quoted sentence: \"The museum opens at nine.\""},
{"role": "user", "content": "When does the museum open?"}
],
"verdictan": {
"context_documents": [{"content": "The museum opens at nine."}]
}
}Send it with the URL and API token from the quickstart:
curl --fail-with-body "$VERDICTAN_BASE_URL/chat/completions" \
-H "Authorization: Bearer $VERDICTAN_CLIENT_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @request.jsonThe nested result shows citation.verified. Now change only the context document to an unrelated sentence and send it again. The result is citation.unverified when the overlap falls below the threshold.
Model wording can vary between calls. For a repeatable test, use a provider fixture that always returns the quoted sentence.
How it works
- The control reads the answer from the provider response, and the
verdictan.context_documents[].contentstrings from the request. - With
verify_against_context, it calculates the groundedness: the share of unique answer words that also appear in the context. - It splits the answer into claims at
.,!,?, and line breaks, and scores each claim against the context. A claim passes atmin_groundednessor above. The claim confidence is the share of claims that pass. - It extracts DOIs, PubMed IDs, URLs, case law citations, regulatory references, and quotes, as
extract_patternsselects. - With
academic, it looks up each DOI atapi.crossref.organd each PubMed ID ateutils.ncbi.nlm.nih.gov. WithurlandVERDICTAN_CITATION_URL_LOOKUP=1ortrue, it performs URL verification using HEAD and, when needed, GET. Each call has a 5-second timeout. - It checks case-law citation formats. With
external_resolver.endpoint, it also sends each case-law and regulatory citation as{"citation": "...", "kind": "case_law"}orregulatoryto that endpoint. The resolver must returnfoundas a boolean. A found result must reachmin_confidenceto count as verified;found: falseidentifies a hallucinated citation. - It decides whether the answer is verified:
- An empty answer passes.
- Without context checks, or without context documents, the answer passes when
require_sourcesisfalse, when source evidence exists, or whenrequire_source_matchisfalse. - With context documents, the overlap must reach
min_context_overlap, the claim confidence must reachmin_confidence, and the source rule must pass.
- A verified answer is allowed with
citation.verified. - A citation confirmed as nonexistent blocks with
citation.hallucinatedwhenhallucination_actionisblock. An otherwise unverified answer blocks withcitation.unverifiedwhenunverified_actionisblock. Other actions keep an allow verdict.
The details contain verified, groundedness, claim_confidence, claims, quotes, citations, and external_lookup. A verified answer adds a verification_report. An unverified answer adds unverified_claims and unverified_claim_count.
Limits and failure behavior
- With
stream: true, the gateway holds the output, runs this control on the complete response, and releases it only when the result permits delivery. - Groundedness counts shared words. A paraphrase of the context scores lower than an answer that reuses its words.
- With
academic, the gateway can call Crossref and PubMed. URL lookups are off unlessVERDICTAN_CITATION_URL_LOOKUPis1ortrue. To avoid external citation calls, removeacademicandurland leaveexternal_resolverunset. A timeout is an unavailable lookup; a confirmed nonexistent citation is governed byhallucination_action. - The runtime and schema defaults include
regulatory. External resolver results are incitations.resolver_results. Resolver errors setcitations.resolver_fallback; an unavailable resolver is not the same asfound: false. flagandredactbehave the same: the answer goes out unchanged with anallowverdict.- Without an external resolver, case-law citations receive a format check only. A resolver response must have a boolean
found; timeouts, non-success responses, and invalid response bodies count as unavailable. - With the defaults and no context documents, an answer without a citation or verified source fails. Set
require_sources: falseon routes that do not use citations.
Starter packs that include this control are in the policy templates hub.
Next steps
- Quality scorer: faithfulness and relevancy thresholds.
- Quality assertion configuration: add assertions next to grounding checks.