Citations
This feature is eligible for Zero Data Retention (ZDR). When your organization has a ZDR arrangement, data sent through this feature is not stored after the API response is returned.
How citations work
Integrate citations with Claude in these steps:1
Provide document(s) and enable citations
- Include documents in any of the supported formats: PDFs, plain text, or custom content documents
- Set
citations.enabled=trueon each of your documents. Currently, citations must be enabled on all or none of the documents within a request. - Note that only text citations are currently supported and image citations are not yet possible.
2
Documents get processed
- Document contents are “chunked” in order to define the minimum granularity of possible citations. For example, sentence chunking would allow Claude to cite a single sentence or chain together multiple consecutive sentences to cite a paragraph (or longer)!
- For PDFs: Text is extracted as described in PDF Support and content is chunked into sentences. Citing images from PDFs is not currently supported.
- For plain text documents: Content is chunked into sentences that can be cited from.
- For custom content documents: Your provided content blocks are used as-is and no further chunking is done.
3
Claude provides cited response
- Responses may now include multiple text blocks where each text block can contain a claim that Claude is making and a list of citations that support the claim.
- Citations reference specific locations in source documents. The format of these citations are dependent on the type of document being cited from.
- For PDFs: Citations include the page number range (1-indexed).
- For plain text documents: Citations include the character index range (0-indexed).
- For custom content documents: Citations include the content block index range (0-indexed) corresponding to the original content list provided.
- Document indices are provided to indicate the reference source and are 0-indexed according to the list of all documents in your original request.
Citable vs non-citable content
- Text found within a document’s
sourcecontent can be cited from. titleandcontextare optional fields that will be passed to the model but not used towards cited content.titleis limited in length so you may find thecontextfield to be useful in storing any document metadata as text or stringified json.
Citation indices
- Document indices are 0-indexed from the list of all document content blocks in the request (spanning across all messages).
- Character indices are 0-indexed with exclusive end indices.
- Page numbers are 1-indexed with exclusive end page numbers.
- Content block indices are 0-indexed with exclusive end indices from the
contentlist provided in the custom content document.
Token costs
- Enabling citations incurs a slight increase in input tokens due to system prompt additions and document chunking.
- However, the citations feature is very efficient with output tokens. Under the hood, the model is outputting citations in a standardized format that are then parsed into cited text and document location indices. The
cited_textfield is provided for convenience and does not count towards output tokens. - When passed back in subsequent conversation turns,
cited_textis also not counted towards input tokens.
Feature compatibility
Citations works in conjunction with other API features including prompt caching, token counting and batch processing.Using Prompt Caching with Citations
Citations and prompt caching can be used together effectively. The citation blocks generated in responses cannot be cached directly, but the source documents they reference can be cached. To optimize performance, applycache_control to your top-level document content blocks.
- The document content is cached using
cache_controlon the document block - Citations are enabled on the document
- Claude can generate responses with citations while benefiting from cached document content
- Subsequent requests using the same document will benefit from the cached content
Document Types
Choosing a document type
Three document types are supported for citations. Documents can be provided directly in the message (base64, text, or URL) or uploaded via the Files API and referenced byfile_id:
.csv, .xlsx, .docx, .md, and .txt files are not supported as document blocks. Convert these to plain text and include directly in message content. See Working with other file formats.
Plain text documents
Plain text documents are automatically chunked into sentences. You can provide them inline or by reference with theirfile_id:
- Inline text
- Files API
PDF documents
PDF documents can be provided as base64-encoded data or byfile_id. PDF text is extracted and chunked into sentences. As image citations are not yet supported, PDFs that are scans of documents and do not contain extractable text will not be citable.
- Base64
- Files API
Custom content documents
Custom content documents give you control over citation granularity. No additional chunking is done and chunks are provided to the model according to the content blocks provided.Response Structure
When citations are enabled, responses include multiple text blocks with citations:Streaming Support
For streaming responses, acitations_delta type is included that contains a single citation to be added to the citations list on the current text content block.