Learning resourcesReviewed · Anthropic

Claude API Citations (Anthropic documentation)

This is Anthropic's official documentation page for the Citations feature of the Claude API, written for developers who want answers tied to passages in their own documents, and its main catch is that citations cannot be combined with structured outputs and cover text only. The page explains how to turn on citations for plain text, PDF and custom content documents, what the cited passages look like in the response, and how to use caching, streaming and a line-per-field pattern to get structured data with citations.

Researched 12 Nov 2026

In short.

This is Anthropic's official documentation page for the Citations feature of the Claude API. It is written for developers who want each claim in a model answer tied to a passage in a document they supplied. The main catch is that citations cannot be used with structured outputs (the API returns a 400 error), and only text can be cited. The page shows how to set citations.enabled on document blocks, how plain text, PDF and custom content documents are chunked, and what char_location, page_location and content_block_location citations contain. It also covers how prompt caching and streaming work with citations, and how to parse a one-line-per-field answer into structured data. The page gives no prices and has no licence or copyright notice. It also doesn't publish the evaluation data behind its claim that citations beat prompt-based quoting.

Researched and written by an AI model and checked by a second AI model. How it works

This report covers one page: the Claude API Citations documentation at [https://platform.claude.com/docs/en/build-with-claude/citations.md]. That includes its front matter, explanatory text, tips and warnings, code samples and sample responses. Pages it links to, such as structured outputs, prompt caching, PDF support, the Files API, search results, streaming and data retention, are outside this scope. Anything said about them here comes only from how this page describes them. The page has no licence or copyright notice, so reuse rights for its text and code samples are unknown. The feature behaviour, token-cost effects and compatibility described here are as the page documents them. The page gives no accuracy, latency or failure-rate figures.

The overview

What this resource is

This is the Citations page of Anthropic's Claude developer documentation, published at [https://platform.claude.com/docs/en/build-with-claude/citations.md]. It documents a Messages API feature in which Claude answers questions about documents you supply and returns the exact source passages that support each claim. The page front matter marks the feature status as stable and lists supported platforms: Claude API, Amazon Bedrock (two entries), Claude Platform on AWS, Claude Models on Google Cloud (Google managed) and Microsoft Foundry.

The resource is a documentation page, not a library or tool. It contains explanatory text, tips and warnings, request examples in cURL, a CLI form, Python, TypeScript, C#, Go, Java, PHP and Ruby, and sample JSON responses.

Overall assessment

This is a clear and fairly complete reference for adding source-grounded answers to a Claude API application. It covers the three document types, the three citation formats, the index conventions, token-cost behaviour, caching, streaming and one important incompatibility. It is most useful as a first read before you build a document question-answering or retrieval-augmented feature.

Keep two things in mind. First, this is vendor documentation. Claims such as citations being guaranteed to contain valid pointers to the provided documents, or being significantly more likely than prompting to cite the most relevant quotes, are Anthropic's own statements. The page publishes no evaluation data behind them. Second, the page gives no accuracy, latency or failure-rate figures, so you will need to check how the feature behaves on your own documents.

Who it is for

The page is for developers who call the Claude Messages API, or use Claude through Amazon Bedrock, Google Cloud, Microsoft Foundry or Claude Platform on AWS, and want to show users where an answer came from. Uses the page suggests include question answering over PDFs or text, and RAG pipelines where each retrieved chunk is passed in as a document.

Beginners can follow the minimal plain text example and the response samples. The parts about custom content documents, index conventions, prompt caching, streaming deltas and the response-parsing steps assume you already know how to build API requests and handle content blocks.

It is not aimed at people who only use Claude through a chat interface. Every example is an API call.

What the feature does, according to the page

Citations return the exact passages that support each claim. Responses can contain several text blocks, each holding a claim and a list of citations. Three document types are supported. Plain text uses sentence chunking and character-index citations (0-indexed, exclusive end). PDF text is extracted and chunked into sentences, with page-number citations (1-indexed, exclusive end page). Custom content uses your content blocks as-is, with block-index citations (0-indexed, exclusive end).

Documents can be provided inline (text, base64 or URL) or by file_id from the Files API. The API extracts the cited_text field. According to the page, cited_text does not count toward output tokens, and it is not counted toward input tokens when passed back in later turns. The page says citations work with prompt caching, token counting and batch processing. It also documents streaming, where each citation arrives as a citations_delta delta type inside content_block_delta events, and a pattern for getting one cited value per field.

Using it

Requirements

The direct Claude API examples use ANTHROPIC_API_KEY. The page does not describe authentication for the listed cloud platforms. The examples send an anthropic-version header of 2026-10-21 and use the model claude-opus-5-5. The front matter lists many supported model identifiers, but the body says all active models support citations and that citations are available on every model. The page does not reconcile the two, so check your target model and platform before relying on the feature.

Each document block needs citations.enabled set to true, and citations must be enabled on all or none of the documents in a request. Only text in a document's source can be cited. Title and context are passed to the model but cannot be cited. PDFs need extractable text. Formats the document block does not support, such as the .docx and .xlsx files the page names, must be converted to plain text first.

The examples use an Anthropic SDK in one of the listed languages, cURL, or the ant command-line tool. The base64 PDF cURL example also uses the base64 and tr shell commands to encode the file. The page does not state SDK version requirements.

How it works

Document contents are chunked to set the smallest unit that can be cited. Plain text and PDFs are split into sentences automatically, and Claude can cite one sentence or chain consecutive sentences into a longer passage. Custom content documents are not chunked further, so each content block you supply is one citable unit. This lets you control granularity for bullet points, transcripts or RAG chunks.

The page says the model internally emits citations in a standardised format, which the API parses into cited text and document locations. Enabling citations slightly increases input tokens because of system prompt additions and chunking. Document indices are 0-indexed across all document blocks in the request, spanning messages.

In responses, a citation object carries a type (char_location, page_location or content_block_location), cited_text, document_index, document_title and start and end positions. When streaming, each citation arrives as a citations_delta inside a content_block_delta event and is added to the current text block's citations list.

Setup steps

The page describes these steps. (1) Include your document as a document content block. Its source type is text (plain text), base64 or url (PDF), file (Files API) or content (custom blocks). (2) Set citations.enabled to true on every document in the request. (3) Optionally add a title and context. (4) Add your question as a text block. (5) Read the response's text blocks and their citations arrays.

If you reuse a large document, add cache_control of type ephemeral to the top-level document block. The page says the citation blocks in responses cannot be cached directly, but the source documents can. The page does not cover API keys, SDK installation or cloud-platform onboarding.

Worked example from the page

The page's main example sends a plain text document titled 'My Document' that contains 'The grass is green. The sky is blue.', with citations enabled, and asks 'What color is the grass and sky?'. A sample response splits the answer into text blocks. One block, 'the grass is green', cites 'The grass is green. ' at characters 0 to 20. Another, 'the sky is blue', cites 'The sky is blue.' at characters 20 to 36.

For structured data, the page suggests asking for one line per field in the form 'field: value' and parsing the lines in your own code. Read the text blocks in order, start a new line at each newline, attach each block's citations to the lines it touches, split each line at the first colon, and check that each field has a value and at least one citation. These outputs are documentation samples, not guaranteed responses. The page notes that the API does not guarantee a value or a citation for every field.

Assessment & evidence

Limitations and cautions

The page states these limits. Only text citations are supported, and image citations are not yet possible. Scanned PDFs without extractable text cannot be cited. Citations must be enabled on all or none of the documents in a request. Citations cannot be used with structured outputs: enabling both (output_config.format or the deprecated output_format) returns a 400 error. Managed Agents are listed as not available for this feature.

Citations are not guaranteed to appear. The page warns that prompts asking for only JSON, such as 'Return only a JSON object, no other text', can produce responses with few or no citations. It also says the API does not guarantee that every field has a value or a citation, so your code should check. The title field has a length limit, so the page suggests putting metadata in the context field. Plain text and PDFs are chunked by sentence, so a cited passage may be a single sentence rather than a full section. The page does not cover real-world accuracy, latency or failure rates.

Reasoning behind this assessment

The page is detailed and specific. It names exact fields, index conventions, error behaviour and a parsing procedure, which makes it a usable reference rather than a marketing overview. Its front matter labels the feature as stable, and the examples use API version 2026-10-21 and model identifiers such as claude-opus-5-5. The page shows no last-updated date, and its maintenance status and update frequency are unknown.

The page has gaps: it gives no pricing, no performance or accuracy data and no licence text. Its claim that citations improve quality over prompting comes from Anthropic's own evaluations, which the page does not publish. Read the behaviour claims as the vendor's documented statements, not independent results.

Alternatives and related options

The page names a few comparisons itself. One is asking Claude in the prompt to quote its sources. The page says that if your prompt-based approach asks Claude to output direct quotes, you might see cost savings with the citations feature because cited_text does not count toward output tokens. It also says citations give more reliable pointers to the provided documents. It offers no data for either comparison. Another option is search result content blocks for RAG pipelines, which the page links to as a separate feature with built-in citation support. It does not describe how that feature works or how it compares. Within citations, custom content documents are the alternative to automatic sentence chunking when you need to control granularity.

If you need strictly schema-validated JSON output, the page indicates citations are the wrong choice because they are incompatible with structured outputs. It suggests the line-per-field approach with your own parsing instead. The page does not compare citations with other vendors' grounding or citation features.

Evidence base

The page backs its claims with documentation detail rather than measurements. It gives front matter on feature status, zero data retention eligibility, supported models and platforms. It also has explanatory sections, tips and warnings, request samples in cURL, a CLI form, Python, TypeScript, C#, Go, Java, PHP and Ruby, and sample JSON responses and streaming events. Its claim that citations beat prompt-based quoting rests on Anthropic's own evaluations. The page provides no data or method for these evaluations and does not say whether they are published elsewhere. The page includes no benchmark figures, accuracy rates or changelog.

Access & freshness

Costs

The page gives no prices. It does say that enabling citations slightly increases input tokens because of system prompt additions and document chunking. It also says cited_text does not count toward output tokens, and cited_text passed back in later turns does not count toward input tokens. The page suggests that asking Claude in the prompt to output direct quotes may use more output tokens than the citations feature, but gives no figures.

The page does not say how large the input-token increase is. Per-token pricing for any model and any charges on Bedrock, Google Cloud, Foundry or Claude Platform on AWS are not stated and remain unknown. The page also gives no pricing or terms for accessing the documentation, so these are unknown too.

Rights and data handling

The page has no licence or copyright statement for the documentation text or the code samples, so reuse rights are unknown. Do not assume the samples can be redistributed under any particular licence.

On data handling, the page says citations are eligible for zero data retention and for HIPAA, for the /v1/messages endpoint. Zero data retention excludes Covered Models, and the page links to the model-specific requirements. This is a statement of feature eligibility only and does not establish compliance for any particular application. The page does not describe the contractual requirements that apply.

Freshness

As of 12 November 2026, the page's front matter labels the feature stable. Its examples use the anthropic-version value 2026-10-21 and model identifiers such as claude-opus-5-5. The page shows no last-updated date, and its maintenance status and update frequency are unknown. Before copying code, confirm the API version, model names and supported-model list against the live page.

Suggested next steps

If you are evaluating citations, first confirm that your model and platform support the feature. Decide early whether you need structured outputs, because the two cannot be combined. Then choose a document type by the citation granularity you need: plain text or PDF for sentence-level citations, custom content for your own chunks.

When building, enable citations on every document in the request and avoid JSON-only prompts. If you need structured fields, use the one-line-per-field prompt and check in code that each field has a value and at least one citation. Add cache_control to large documents you reuse. The page gives no prices, so check Anthropic's or your cloud provider's pricing pages. Because the page gives no accuracy figures, try the feature on your own documents before relying on citation coverage or accuracy.

Evidence for this report

selected-page.txtselected · checked 2026-11-12