OpenAI Chat Citations

OpenAI web-search chat models return `url_citation` annotations alongside the content.

OpenAI web-search chat models return url_citation annotations alongside the content. Agno surfaces these on response.citations.

This is a legacy Chat Completions search example. The model card lists the gpt-4o-search-preview-2025-03-11 snapshot, whose shutdown date was July 23, 2026. For a new integration, use the Responses example below. The alias's live availability has not been verified here.

citations.py
"""
Openai Chat Citations
=====================

Cookbook example for `openai/chat/citations.py`.

OpenAI web-search chat models return
`url_citation` annotations alongside the content. Agno surfaces these on
`response.citations`.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# `gpt-4o-search-preview` performs a web search and attaches url_citation
# annotations to the response.
agent = Agent(model=OpenAIChat(id="gpt-4o-search-preview"), markdown=True)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What are the latest developments in AI? Cite your sources.")

Current Alternative

Save this complete Responses API example as citations_current.py. Agno exposes returned web citations on result.citations; whether a response searches and returns citations depends on the model's tool use.

citations_current.py
from agno.agent import Agent
from agno.models.openai import OpenAIResponses

agent = Agent(
    model=OpenAIResponses(id="gpt-5.6-terra"),
    tools=[{"type": "web_search"}],
    markdown=True,
)
result = agent.run("What are the latest developments in AI? Cite your sources.")
print(result.content)
if result.citations:
    print(result.citations)

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the current alternative as citations_current.py, then run:

python citations_current.py

Full source: cookbook/90_models/openai/chat/citations.py