Knowledge and RAG
Sources and citations
The sources event in the stream, its fields, when it's sent, and how the agent cites documents and web pages in its answer.
Reference1 min readUpdated 23 October 2026
When an answer uses knowledge, your app hears about it twice: a structured sources event before the answer, and source lines the model writes at the end of the answer.
The sources event
Sent once, before the first delta, when knowledge context was added and at least one passage can be cited. A cached answer replays its sources too.
data: {"type": "sources", "sources": [ {"index": 1, "id": "...", "title": "Returns and refunds", "url": "https://example.com/returns", "filename": null, "source_type": "web", "score": 0.84, "snippet": "Unworn items can be returned within..."}, {"index": 2, "id": "...", "title": "Warranty terms", "url": null, "filename": "warranty-2026.pdf", "source_type": "document", "score": 0.71, "snippet": "..."}]}| Field | Meaning |
|---|---|
index | Position, starting at 1 |
id | The chunk's id |
title | The page title or document name |
url | The page address for web sources, otherwise null |
filename | The file name for documents, otherwise null |
source_type | document, web, faq (a snippet) or qa |
score | The relevance score after reranking |
snippet | The start of the passage, up to 240 characters |
Citations in the answer text
The model is told not to cite inline, and to end its answer with one line per source it used: a web page as a markdown link, a document as its file name. Snippets and Q&A pairs are internal knowledge and are never cited.
Worn items can't be returned, but faults are covered for 12 months.Source: [https://example.com/returns](https://example.com/returns)Source: warranty-2026.pdfShowing sources in your app
- Render the
sourcesevent as a citations panel as soon as it arrives, before the answer finishes. - Use
urlto link out, orfilenameto label a document. - Log the ids and scores with your request id to investigate answers later.
- The widget shows the answer text, including its source lines, rendered as markdown.
Still stuck?
Email us with what you tried and any request id. A person replies.