CONCEPT Provide the source, then constrain the answer to it
Grounding means the answer is derived from documents you supply rather than the model's training data. It's the structural cousin of 8.1: where 8.1 lowers the pressure to answer, grounding gives Claude the material and then restricts it to that material. Three moves compose it:
- Provide the source documents in the prompt — ideally inside XML tags like
<documents>…</documents>so Claude can tell context from instruction. - Ask Claude to quote the passages it used and cite them per claim — making the answer auditable and self-correcting.
- Verify claims against the source after generation: for each claim, find a supporting quote; if none exists, drop the claim.
[] brackets." Claude polices its own output against the source.CONCEPT The Citations capability (high level)
Beyond prompting Claude to quote passages, the Claude API has a built-in Citations feature
that grounds answers structurally rather than by instruction. You set citations: {enabled: true}
on each document content block; the response then splits into multiple text blocks,
and cited blocks carry a citations array. Each citation gives you the cited_text, the
document_index, the document_title, and a location — char_location for
plain text or page_location (1-indexed pages) for PDFs.
output_config.format) — combining them returns a 400. The model produces verifiable references to
exact source spans instead of you parsing quotes out of prose.DIAGRAM Prompted quoting vs. the Citations feature
in the request"] --> C{"How to ground?"} C -->|"prompt technique"| PQ["Ask Claude to quote
+ cite each claim in prose"] C -->|"API feature"| CF["citations: enabled
on every document block"] PQ --> V["Verify each claim
against a quote; retract if none"] CF --> R["🟢 Response splits into text blocks;
cited blocks carry cited_text +
document_index + location"] V --> A["🟢 Auditable, source-backed answer"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class A ok; class R ok; class V gate;
CODE Grounding prompt + the Citations request shape
First, the pure-prompt grounding pattern with a self-verification pass:
# Prompt-only grounding: quote, cite, and self-verify
Draft a press release for AcmeSecurity Pro using ONLY information from these briefs.
<documents>{{DOCUMENTS}}</documents>
After drafting, review each claim in the release. For each claim, find a direct
quote from the documents that supports it. If you cannot find a supporting quote,
remove that claim and mark where it was with empty [] brackets.
And the API-native Citations feature — grounding enforced by the platform, not by instructions:
import anthropic client = anthropic.Anthropic() resp = client.messages.create( model="claude-opus-4-8", max_tokens=1024, messages=[{"role": "user", "content": [ {"type": "document", "source": {"type": "text", "media_type": "text/plain", "data": policy_text}, "title": "Privacy Policy", "citations": {"enabled": True}}, # all docs or none {"type": "text", "text": "Which sections cover data retention?"}, ]}], ) for block in resp.content: if block.type == "text": print(block.text) for c in (block.citations or []): print(" ↳ cited:", c.cited_text, "@", c.document_title)
TRADE-OFFS Prompted quoting vs. the Citations feature
| Prompt Claude to quote | Citations feature | |
|---|---|---|
| Setup | Just prompt wording | citations: {enabled: true} per document |
| Enforcement | Instruction — model may drift | Structural — returns exact spans + offsets |
| Output shape | Free prose with inline quotes | Text blocks with a citations array |
| Limits | None, but weaker guarantee | All-or-none; incompatible with output_config.format |
EXAM TRAPS
citations on some documents but not others in one request. →
It's all documents or none — a mixed request is rejected.output_config.format). →
Incompatible — returns a 400. Pick one: cited spans or a JSON schema, not both in the same call.PRACTICE
Q1 · A RAG answer looks right but you can't tell which retrieved chunk each sentence came from. Which capability fixes this and how?
Enable the Citations feature (citations: {enabled: true}) on each document
block. The response splits into text blocks where cited blocks carry a citations array with
cited_text, document_index/title, and a char- or page-location — so every sentence
traces to an exact source span.
Q2 · You need both citations and a strict JSON schema in one call. What happens?
You can't — Citations is incompatible with output_config.format and the
request returns a 400. Split it into two steps (cite first, then structure) or choose the one the task needs
most.
Q3 · Without the Citations feature, how do you make a drafted document self-verify against its sources?
Add a verification pass to the prompt: after drafting, have Claude find a direct supporting
quote for each claim and remove any claim it can't support (e.g. marking the gap with empty
[] brackets). This grounds and audits the output using prompting alone.