Skip to contents

Create a content block referencing an uploaded file for use in messages.

Usage

claude_file_content(file_id, title = NULL, context = NULL, citations = FALSE)

Arguments

file_id

Character. The file ID from claude_file_upload().

title

Character. Optional document title for context.

context

Character. Optional context about the document.

citations

Logical. Enable citation tracking. Default FALSE.

Value

A content block for use with chat$chat().

Details

Creates a document content block that references a previously uploaded file. Pass this to chat$chat() to include the document in your conversation.

When citations = TRUE, Claude's response will include citation blocks referencing specific passages.

API Reference: https://platform.claude.com/docs/en/build-with-claude/files

Examples

if (FALSE) { # \dontrun{
# Upload and reference file
file <- claude_file_upload("report.pdf")
chat <- claude_new()
chat$chat(
  claude_file_content(file$id, title = "Q4 Report"),
  "What are the key findings?"
)

# With citations enabled
chat$chat(
  claude_file_content(file$id, citations = TRUE),
  "Cite specific sections about revenue growth"
)
} # }