[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

Document-Grounded Citations

📎 Citations & Files API⏱ 20 min⭐ 550 BASE XP⌨ HANDS-ON LAB

Precision Source Attribution

The Citations API (anthropic-beta: citations-2025-02-28) 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.

Citation Types

TypeGranularityBest For
char_locationCharacter-level offsetPlain text documents
page_locationPage number + bounding boxPDF documents
content_block_locationBlock index referenceStructured content arrays

Enabling Citations

const response = await anthropic.messages.create({
  model: "claude-3-7-sonnet-20250219",
  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." }
    ]
  }]
});
⌨ HANDS-ON LABEnable Grounded Citations & Document Sources
⭐ +200 XP

Prevent hallucination in legal and technical workflows. Pass document content blocks with citations enabled and inspect the cited span.

1POST a document block with citations enabled in /v1/messages.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 1
What is the primary benefit of the Citations API?
Faster generation speed
Grounding claims with verifiable source references to reduce hallucination
Lower token usage
Automatic translation