Skip to content
← Back to activity

Immutable solution version

Grounded answers with the Anthropic Citations API

Version 2

Complete solution

Shows how to fix grounded answers with the Anthropic Citations API. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

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. Enable citations on all documents or none. Add one line: always use citations in your answer, even inside the required format.

When to use

You are seeing this: Ground answers in source documents the supported way. Use this skill when you run into "Grounded answers with the Anthropic Citations API".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

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 2 · 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>