Class AnthropicCitationDocument

java.lang.Object
org.springframework.ai.anthropic.AnthropicCitationDocument

public final class AnthropicCitationDocument extends Object
Builder class for creating citation-enabled documents using the Anthropic Java SDK. Produces SDK DocumentBlockParam objects directly.

Citations allow Claude to reference specific parts of provided documents in its responses. When a citation document is included in a prompt, Claude can cite the source material, and citation metadata (character ranges, page numbers, or content blocks) is returned in the response.

Usage Examples

Plain Text Document:


 AnthropicCitationDocument document = AnthropicCitationDocument.builder()
     .plainText("The Eiffel Tower was completed in 1889 in Paris, France.")
     .title("Eiffel Tower Facts")
     .citationsEnabled(true)
     .build();
 

PDF Document:


 AnthropicCitationDocument document = AnthropicCitationDocument.builder()
     .pdfFile("path/to/document.pdf")
     .title("Technical Specification")
     .citationsEnabled(true)
     .build();
 

Custom Content Blocks:


 AnthropicCitationDocument document = AnthropicCitationDocument.builder()
     .customContent(
         "Fact 1: The Great Wall spans 21,196 kilometers.",
         "Fact 2: Construction began in the 7th century BC.",
         "Fact 3: It was built to protect Chinese states."
     )
     .title("Great Wall Facts")
     .citationsEnabled(true)
     .build();
 
Since:
1.1.0
Author:
Soby Chacko
See Also:
  • Method Details

    • builder

      public static AnthropicCitationDocument.Builder builder()
    • toDocumentBlockParam

      public com.anthropic.models.messages.DocumentBlockParam toDocumentBlockParam()
      Convert this citation document to an SDK DocumentBlockParam.
      Returns:
      configured DocumentBlockParam for the Anthropic API
    • isCitationsEnabled

      public boolean isCitationsEnabled()