الانتقال إلى المحتوى
Claude وأدوات الـ AI للبرمجةClaude API و Tool Use· 7 دقائق للقراءة

'Cite Your Sources' in a Prompt Isn't Grounding: Use Claude's Citations Feature

A citation Claude writes because you asked is just more text. The Citations feature returns exact, verifiable locations in your documents.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
  • Claude API
محتويات المقال

Your HR assistant answers employee questions from the handbook, and its system prompt says "Cite every claim as [Handbook §x.y]". A contractor asks about the annual bonus and gets: "Contractors with 12 months of service are eligible [Handbook §4.2]." HR opens §4.2 and finds the parental leave policy. The handbook says bonuses are for employees only. The answer looked exactly like the hundreds of correct ones, with the same confident bracket at the end, and nothing in the pipeline could tell them apart.

The common misconception

"Asking Claude in the prompt to cite sources yields citations that reliably point to real passages in your documents." There are good reasons to believe it:

  • Claude follows formatting instructions well, so every answer comes back with neat, consistent references.
  • Spot checks pass: most prompted citations are right, which makes the wrong ones rare and easy to miss.
  • Anthropic's own guide to reducing recommends asking Claude to quote and cite.
  • A reference with a section number and quote marks looks like something a system verified.

The half-truth: asking for quotes is a real technique. The same guide says these techniques "significantly reduce hallucinations", and adds that "they don't eliminate them entirely". A prompted citation makes an answer easier to audit by hand. It doesn't give your code anything it can trust.

What actually happens

A prompted citation is just more output

When you ask for "[Handbook §4.2]", Claude writes those characters the way it writes every other word. Nothing in the API compares them with your document. A section number can be wrong, a "quote" can be a paraphrase, and the format can drift. To use them in a product, you'd parse references out of prose with a regular expression and search the source for each quote yourself, and you'd still have no answer when the quote doesn't match exactly.

The Citations feature returns pointers, not prose

With the Citations feature, the sources go in as document blocks with "citations": {"enabled": true}, and the API does the bookkeeping:

  1. Your documents are chunkedPlain text and PDFs are split into sentences; custom content documents keep the blocks you provide, with no further chunking. A chunk is the smallest thing Claude can cite.
  2. Claude answers in blocksThe response becomes several text blocks. A block that makes a claim from your documents carries a citations list.
  3. The API attaches exact locationsEach citation has the cited_text, a document_index, the document_title and a location: character range for plain text, page range for PDFs, block range for custom content.

Here is one cited block, as the docs show it:

JSON response.content[1]
{  "type": "text",  "text": "the grass is green",  "citations": [{    "type": "char_location",    "cited_text": "The grass is green. ",    "document_index": 0,    "document_title": "Example Document",    "start_char_index": 0,    "end_char_index": 20  }]}

Because the API parses the citations and extracts cited_text itself, the docs state that they "are guaranteed to contain valid pointers to the provided documents". cited_text also doesn't count toward output tokens, so if you used to ask Claude to copy quotes out, you might pay less.

What the guarantee doesn't cover

A valid pointer means the passage exists, at that location, in that document. It doesn't mean the passage supports the sentence it's attached to; that's still Claude's judgment. Anthropic reports that in its evaluations the feature is "significantly more likely to cite the most relevant quotes" than prompting, which is better, not perfect. And not every block gets a citation. Joining text has none, and neither does a claim Claude didn't draw from your documents. In the docs' own words about extracted fields, "The API doesn't guarantee either", meaning a value and a citation for each one.

Rewriting the assistant

The first version asks for citations in the prompt. The second sends the handbook as a document and reads the citations the API returns:

Python hr_answer.py
import anthropicclient = anthropic.Anthropic()reply = client.messages.create(    model="claude-opus-5-5", max_tokens=2048,    system="Answer from the handbook. Cite every claim as [Handbook §x.y].",    messages=[{"role": "user",               "content": f"<handbook>{HANDBOOK}</handbook>\n{QUESTION}"}],)answer = next(b.text for b in reply.content if b.type == "text")print(answer)  # "[Handbook §4.2]" is text Claude wrote; nothing checked it

The second version prints each piece of the answer next to the exact handbook sentences behind it, and the pieces with no citation are easy to spot, flag or hide.

"Cite your sources" in the promptCitations feature
Where the reference comes fromGenerated textParsed by the API from your documents
Can it point to text that isn't there?YesNo: pointers are guaranteed valid
The quoted passageWritten by Claude, may be paraphrasedcited_text, copied from the document
Reading it in codeA regex over prosedocument_index plus a char, page or block range
Proves the claim?NoNo, but the evidence is one click away

How to apply it in your project

  1. Find prompted citationsSearch your prompts for "cite", "source" and "quote", and your code for regexes that parse references out of answers.
  2. Send sources as cited documentsPass each source as a document block with citations enabled. It's all or none: every document in the request must have the same setting.
  3. Render from the citations arrayShow cited_text and link to the page or character range, instead of trusting references written in the answer.
  4. Treat uncited claims as unsupportedA factual sentence without a citation is a signal: flag it, hide it, or send it for review.
  5. Check relevance in your evalsOn a sample of answers, check that each cited_text actually supports its sentence. A valid pointer can still point at the wrong passage.

Key takeaways

  • A citation you ask for in the prompt is generated text; nothing checks it against your documents.
  • The Citations feature returns structured locations whose pointers are guaranteed valid, plus cited_text that doesn't count toward output tokens.
  • A valid pointer isn't proof: whether the passage supports the claim is still Claude's judgment.
  • Uncited text blocks exist, so decide in code what to do with claims that have no citation.
  • Citations and structured outputs don't mix; use one line per field when you need both.

📚 المصادر

  1. Citations — Claude API Docs
  2. Search results — Claude API Docs
  3. Reduce hallucinations — Claude API Docs

التعليقات (0)