The Citations API enables Claude to ground its responses in specific passages from provided documents. When enabled, every claim in Claude's response includes a reference to the exact sentence, paragraph, or page it was derived from — dramatically reducing hallucination risk.
| Type | Granularity | Best For |
|---|---|---|
char_location | Character-level offset | Plain text documents |
page_location | Page number + bounding box | PDF documents |
content_block_location | Block index reference | Structured content arrays |
// Request with citations
const response = await anthropic.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 4096,
citations: { enabled: true },
messages: [{
role: "user",
content: [
{ type: "document", source: { type: "base64", media_type: "application/pdf", data: pdfBase64 }, title: "Contract.pdf" },
{ type: "text", text: "Summarize the key obligations in this contract with citations." }
]
}]
});