Convenience function to create a document block with citations enabled.
Details
When citations are enabled, Claude's response will include citation blocks
that reference specific passages. Citation locations include:
char_location: Character offsets in plain textpage_location: Page numbers in PDFscontent_block_location: Index in multi-block documents
For inline documents (file paths), the file is base64-encoded and included in the request. For uploaded files (file_id strings), only the reference is sent.
API Reference: https://www.anthropic.com/news/introducing-citations-api
Examples
if (FALSE) { # \dontrun{
# Inline document with citations
chat <- claude_new()
response <- chat$chat(
claude_doc_cite("contract.pdf", title = "Service Agreement"),
"What are the termination conditions? Cite specific clauses."
)
# Uploaded file with citations
file <- claude_file_upload("report.pdf")
chat$chat(
claude_doc_cite(file$id, title = "Q4 Report"),
"Summarize with citations"
)
} # }
