Claude With The Anthropic Api
← All lessons
Lesson 54Claude With The Anthropic Api

Citations

Summary audio

No audio recap for this lesson.

Study notes

Overview

  • Citations allow Claude to reference outside sources when generating answers
  • Users can verify that Claude's responses are based on actual documents rather than just generated text
  • Citations work with both PDF documents and plain text

Citation Page Location (for PDFs)

  • Used when Claude cites information from PDF documents
  • Contains five key components:
  • Cited text: The exact text from the source document supporting the statement
  • Document index: Identifies which document is being referenced
  • Document title: The name of the source document (e. g. , earth. pdf)
  • Start page: Where the cited information begins
  • End page: Where the cited information ends

Citation Char Location (for Plain Text)

  • Used when Claude cites information from plain text sources
  • Provides character position within the text block instead of page numbers
  • Allows precise location tracking within unstructured text

Implementation

  • Enable citations by adding a citations field with enabled: true to the request
  • Include a title field to identify the source document
  • Specify type as either "document" (PDF) or "text" (plain text)
  • For text sources, set media_type to "text/plain"

User Interface Benefits

  • Citations enable building interfaces with hover-over pop-ups showing source information
  • Users can verify Claude's accuracy by checking the original source documents
  • Increases transparency and trustworthiness of AI-generated responses

Takeaways

  • Citations allow Claude to reference and verify information from external sources (PDFs or plain text), making responses traceable to actual documents
  • For PDFs, citations include the exact cited text, document title, and page range; for plain text, they provide character positions instead of page numbers
  • Enable citations by adding citations: enabled: true to the request along with document title and type fields
  • Citation features support UI elements like hover-over pop-ups that display source information, increasing transparency and user trust in AI responses
Flashcards 8 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions