Pydantic AI connects answer citations with saved chats
3-line summary
- Version 2.61.0 adds a common citation format and provider and UI support.
- Citations kept in the frontend differ from those replayed to a model.
- Provider, output and streaming choices still determine what survives.
The Python AI SDK Pydantic AI has added a common way to collect answer citations and connect them with saved conversations and web chat interfaces. Version 2.61.0, released October 24, includes four coordinated changes covering citation data, additional providers, history replay and the Vercel AI adapter.
Citations attach to the text portion of a model response. They pair web or document sources with a character range where that relationship can be checked; otherwise the range is absent. The documentation cautions that listed sources can copy one another, so a larger number does not establish stronger support.
The Vercel AI adapter lists each cited web page once per message. Received citations survive in text metadata when a frontend stores and returns history. Document sources stay outside the web-page list.
Metadata includes excerpts and original provider citation data, potentially carrying a user’s document content. Client-supplied citations are checked for structure and fit within the text. Invalid entries are dropped while others survive.
Provider differences remain. On Amazon Bedrock, document citations cover text and PDFs on supported Anthropic models, excluding S3 documents. OpenRouter supplies no usable position in the answer. With xAI, enabling citations makes the model write Markdown markers. The Citations option does not request citations for structured output on Bedrock or xAI. Other Bedrock models ignore the setting, and text documents must be UTF-8 when citations are enabled or a user error is raised. Bedrock document titles follow their order, with names such as Document 1.
Saving citations does not mean replaying all of them
Replay is narrower than storage. Returning history to its original provider supports Anthropic web-search citations and OpenAI Responses URL and file annotations. Responses also needs the original message ID. Position-based document citations and history switched to a different provider go back as plain text.
Document references use the request’s document order. Trimming or editing can make the same position identify another document, so these references are not replayed unchanged. Edits that keep the answer’s length can also evade change detection.
When consecutive text parts merge for the web interface, citation positions move too. Anthropic web-search citations must cover their entire original text part. After merging, those citations remain in metadata while the answer returns to Anthropic as plain text.
Citations can arrive after text during streaming. Google and OpenAI Chat deliver them at the response’s end, so the documentation directs readers to the completed response for citations. A separate interface integration, the AG-UI adapter, does not send citation data to the frontend.
Sources
- v2.61.0 release — Pydantic AI
- Structured citations on TextPart — #7434 — Pydantic AI
- Bedrock, OpenRouter and xAI citation mapping — #7750 — Pydantic AI
- Provider-specific citation replay — #7752 — Pydantic AI
- Citations through the Vercel AI adapter — #9639 — Pydantic AI
- Project overview — release-pinned README — Pydantic AI