Dashboard

How to Prompt AI to Cite Its Sources

A plausible-looking URL is the most dangerous output a model produces, because it looks like evidence. Set the request up so citations can be real, then check them.

Steve Jefferson
Steve Jefferson
Developer Advocate
21 October 20261 min read

Asking a model to cite its sources produces citations. Whether those citations exist is a separate question, and the answer depends entirely on whether the model had documents or search results in front of it when it answered. If it did, a citation is a pointer to text you can check. If it did not, a citation is generated prose in the shape of a reference, and a plausible-looking URL is the most dangerous output a model produces because it looks like evidence.

So the real technique has two halves: set up the request so citations can be real, then verify them anyway.

The two situations, which behave completely differently

With sources attached. You supplied documents, or the tool ran a search and put the results in context. Now the model is reading specific text and pointing at it. Citations here are checkable, and getting them accurate is mostly a prompting problem.

Without sources attached. The model is answering from what it absorbed during training. It has no record of where anything came from, because training does not store page addresses alongside facts. Any citation it offers is reconstructed from the pattern of what citations look like. Sometimes it lands on a real paper. Often it produces a real author, a real journal and a title that does not exist.

The most common way people get burned is a tool that could have searched and did not, for a question that sounded like general knowledge. Check whether search actually ran before you trust a link.

Prompts that work when sources are attached

The weak version is "cite your sources". The strong version pins down three things: where citations may come from, what form they take, and what to do when the sources do not answer the question.

text
Answer using only the documents I have attached.

For every factual claim, quote the exact sentence from the source
that supports it, followed by the document name and section.

If the documents do not contain the answer, say "Not in the
provided sources" and stop. Do not fill the gap from general
knowledge. Do not combine a document with something you already
know without labelling which part came from where.

The quoting requirement is what makes this work. A summary cannot be checked without rereading the source, but a quote can be found with Ctrl-F in four seconds. Verification cost is the whole game: a citation you will not check is decoration.

The "Not in the provided sources" instruction matters just as much. A model that has been told to cite will cite something, and if the sources do not cover the question it will attach the nearest passage to an answer that came from elsewhere. Giving it a permitted way to fail prevents that.

When the question is about current events

Add one constraint that rules out the commonest failure:

text
Search before answering. For each claim, give the publication date
of the page you took it from, and prefer the primary source: the
company's own announcement, the official documentation, or the
regulator's own release, over coverage of it.

If the most recent source you found is older than my question
implies, say so explicitly rather than answering from memory.

That last clause catches the quiet error where you ask about something from last week and get a confident answer built from a page written in spring. A model's internal sense of "recent" is anchored to its training data, not to today, which is covered in why the model is out of date.

The feature that solves this properly

If you are building on an API rather than typing into a chat window, prompting is the wrong layer to fix this at. Several providers now return citations as structured data rather than as text in the answer.

Anthropic's citations feature is the clearest example: you attach a document with "citations": {"enabled": true}, and the response comes back with the exact passages that support each claim, as described in the documentation, so you can verify answers and surface sources to your users. It is generally available and supported across the active models.

The difference is structural rather than cosmetic. A citation generated inside the prose is text the model wrote, and nothing checks it. A citation returned as a separate field with a character range into a document you supplied is a reference to text that demonstrably exists, because you provided the text. One can be wrong in a way the other cannot.

If your product shows AI answers to users, this is the version to build on. Prompting for inline citations and displaying them unverified is how you end up publishing a fabricated reference with your own name on it.

A verification routine that takes two minutes

Whatever the setup, before anything leaves your hands:

  1. Open every link. Not the ones that look doubtful. All of them. A dead link, a redirect to a homepage, or a page that exists but does not contain the claim are the three failure modes, in rising order of embarrassment.

  2. Search the page for the quoted sentence. If the quote is not there verbatim, the citation is wrong even if the page is relevant.

  3. Check the date on the page against the claim.

  4. For anything numeric, confirm the number on the page rather than reading past it. Transposed digits and dropped units survive every other check.

  5. For anything that will be published or sent to a client, find one source the model did not give you. If no independent source says the same thing, treat the claim as unverified.

Step five is the one that separates research from laundering. If a single page is the only support for a claim, you are repeating that page, not confirming it.

What to do when a citation turns out to be invented

Do not ask the model to fix it. The follow-up "that link does not work, please give the correct one" produces another plausible link, because the failure was never a retrieval mistake it can correct. It was generation.

Instead, remove the claim, search for it yourself, and if you cannot find support, delete it. Then go back and treat every other uncited claim in the same answer with suspicion, because a fabricated citation is a signal about the whole response rather than one bad line.

The related techniques are worth combining: prompting a model to check its own work catches a different class of error, and giving it a worked example rather than rules is the more reliable way to get a citation format you can parse.

Frequently asked questions

Why does the model invent URLs that look so real?

Because it has read millions of real ones and learned their shape. A path built from plausible words under a real domain is exactly what the pattern predicts, and nothing in the process checks whether that address was ever issued.

Does asking for a page number help?

With a document attached, yes, it narrows where to look. Without one, it makes things worse, because a specific page number adds confidence to a reference that may not exist.

Is deep research mode more reliable?

Generally yes, because those modes actually retrieve pages and keep track of which claim came from which one. They still need step one of the routine above.

Can I just tell it never to make things up?

No. That instruction has no mechanism behind it. What has a mechanism is restricting the model to text you supplied, requiring verbatim quotes, and giving it a sanctioned way to say the answer is not there.

For the underlying framework these techniques sit inside, see our guide to prompt engineering.

How did this land?

About the author

Steve Jefferson
Steve Jefferson

Developer Advocate

Steve builds something with Swarmz every week and writes up what worked, what broke, and what he'd do differently. Tutorials and hands-on guides are his lane.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.