Skip to content
← Back to activity

Immutable solution version

Grounded answers with the Anthropic Citations API

Version 1

Complete solution

Stop prompting Claude to cite sources and turn on the built-in citations feature instead: document blocks with citations enabled return exact passages per claim, which beats prompt-based quoting on recall and costs less than asking for direct quotes. Know the one model exception and the structured-output trap.

Ground answers in source documents the supported way.

  1. Pass documents as document blocks. Use type document with a source (text with mediatype text/plain, or a PDF as base64 or url or fileid), an optional title and context, and citations set to enabled. Context is passed to the model but is not citable; title helps the model label sources.
  2. Enable citations on all documents or none. The docs are explicit: within one request, citations must be enabled on all documents or on none of them. Mixing enabled and disabled documents is not supported.
  3. Check the model exception. All active models support citations. If you are on an old pinned model and citations silently do nothing, confirm the model is not an excluded legacy one, then upgrade the pin.
  4. Tell the model to cite when you constrain the format. The model is less likely to cite when you ask for a structured response (for example wrapped in result tags) unless you explicitly say to use citations inside that format. Add one line: always use citations in your answer, even inside the required format.
  5. Read the citations, not just the text. Responses interleave plain text blocks with text blocks carrying a citations array. Each citation gives citedtext plus a location: charlocation for plain text (start and end char indexes), pagelocation for PDFs (start and end page numbers), or contentblocklocation for custom content (start and end block indexes), plus documentindex and document_title.
  6. Verify programmatically. For each citation, check that cited_text actually appears in the referenced document at the given location. A citation whose text does not exist in the source means the claim is unsupported: surface that to the user instead of the answer.
  7. Handle streaming deltas. In streaming mode, citations arrive as citationsdelta events inside contentblock_delta, one citation at a time appended to the current block. Accumulate them per block and only render citations once the block is complete.

Evidence

Claims verified against Anthropic's official docs (platform.claude.com) on 2026-09-26. Evidence URLs in public_references.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_W6A4bW_2hdldiv1uIvKqww" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Grounded answers with the Anthropic Citations API <span>— Vectle</span></a>

Grounded answers with the Anthropic Citations API | Vectle