In short. Read response.inline_citations after the Grok stream finishes to access the accumulated structured inline citation records.
Definition: A structured citation record is the metadata attached to an inline citation, including its URL, label and character range in the response text. During a Grok stream, xAI makes records available per chunk and exposes the accumulated inline citation records on the final response.
Key facts
- xAI separates all citations, which list sources encountered during the search, from inline citations, which are links embedded in the response text. xAI's citation documentation describes both forms.
- The
response.citationscollection is returned when the agentic request completes, and it can contain a URL that the final answer does not reference directly. The same documentation describes this collection. - Each
output_textcontent block can include anannotationsarray with a URL, character offsets and a label. The documented response format gives this structured shape. - During streaming, inline citation links appear in
chunk.content, per-chunk records are available throughchunk.inline_citations, and the accumulated records are available throughresponse.inline_citations. The streaming citation section lists these access points.
What does a citation record contain?
xAI's citation documentation defines an inline citation annotation with the type url_citation, a source URL, a starting character position, an ending character position, and a title. The ending position is exclusive, so a parser can slice the response text with the documented start and end indexes. The title is the visible citation number for text citations, such as 1 or 2.
The documentation gives the following fields as the structured representation:
{
"type": "url_citation",
"url": "<source URL>",
"start_index": "<start position>",
"end_index": "<exclusive end position>",
"title": "<citation label>"
}
The example shows the shape only. The URL, positions and label belong to the particular response.
What can arrive before the final response?
xAI's streaming documentation states that streaming uses Server-Sent Events to send content deltas in event streams. The request enables this mode with "stream": true. The citation page adds that markdown links appear in real time in chunk.content as the model generates text, and that citation records can be read from each chunk.
That makes per-chunk data suitable for displaying citations while text arrives. A chunk is an observation during the stream. It is not the accumulated final collection described by xAI.
When should an application finalize the collection?
The final-response boundary is the point to read the complete inline citation collection. xAI's streaming citation section states that inline citations are accumulated and available on the final response. The documented access pattern is:
# After streaming, access all accumulated inline citations
for citation in response.inline_citations:
print(citation.id)
An application can retain per-chunk records for live output, then read response.inline_citations after the stream has finished. The separate response.citations collection answers a different question: it contains URLs encountered by the agent's search process, including sources that may not appear as inline references in the final answer.
Related terms
FAQ
Should you treat the first citation-bearing chunk as complete?
No. You can inspect chunk.inline_citations while the stream runs, but xAI documents the accumulated inline citation collection on the final response.
Can the all-citations list be longer than the inline list?
Yes. The documentation says that response.citations contains all URLs encountered during the search process, and that some URLs may not be directly referenced in the final answer.
Which positions should you use to extract the citation text?
Use start_index and end_index from the structured annotation. xAI defines the ending position as exclusive, so you can use the pair as a text slice boundary.
Sources
- xAI, "Citations", August 25, 2026
- xAI, "Streaming", October 10, 2026
- xAI, "Streaming & Synchronous Requests", October 10, 2026
Check how a page reads to answer engines. Open the GEO score analyzer