# Model content vs search\_results & citations references

**URL:** <https://community.perplexity.ai/t/model-content-vs-search-results-citations-references/1165>\
**Category:** General\
**Created:** [August 22, 2025, 8:50pm UTC](https://community.perplexity.ai/t/model-content-vs-search-results-citations-references/1165 "2025-08-22T20:50:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Kesku](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/kesku/32/898_2.png) [@Kesku](https://community.perplexity.ai/u/Kesku)\
**Post date:** [April 7, 2026, 2:41pm UTC](https://community.perplexity.ai/t/model-content-vs-search-results-citations-references/1165/2 "2026-04-07T14:41:46Z")

</div>

Hey @SDCUF — good question. In streaming mode, the `citations` and `search_results` fields arrive in the **final chunk** of the stream, not in every chunk. Here is how it works:

- During streaming, `delta.content` gives you the text incrementally with inline citation markers like `[1]`, `[2]`, etc.
- The `citations` array (list of URLs) appears in the **last chunk** where `finish_reason` is set to `"stop"`.
- The inline `[1]` markers correspond to indices in that `citations` array.

To properly collect citations while streaming:

```python
from perplexity import Perplexity

client = Perplexity()
stream = client.chat.completions.create(
    model="sonar-pro",
    messages=[{"role": "user", "content": "How many stars in our galaxy?"}],
    stream=True
)

full_text = ""
citations = []

for chunk in stream:
    if chunk.choices[0].delta.content:
        full_text += chunk.choices[0].delta.content
    # Citations appear in the final chunk
    if hasattr(chunk, "citations") and chunk.citations:
        citations = chunk.citations

print(full_text)
print("Sources:", citations)

```

Since you are using the OpenAI SDK, the `citations` field will not be typed on the response object — you will need to access it from the raw response dict or switch to the [Perplexity SDK](https://docs.perplexity.ai/docs/getting-started/quickstart) which has proper typing for these fields.

Alternatively, the **Agent API** returns citations as annotations on the output, which can be easier to work with:

```python
response = client.responses.create(
    preset="pro-search",
    input="How many stars in our galaxy?"
)
# Citations are in response.output[].content[].annotations

```

Docs: [Sonar Streaming](https://docs.perplexity.ai/docs/sonar/quickstart) | [Agent API](https://docs.perplexity.ai/docs/agent-api/quickstart)

---

_[View the full topic](https://community.perplexity.ai/t/model-content-vs-search-results-citations-references/1165)._
