Skip to content

Comments

docs: add citation guides for OpenAI and Anthropic#3146

Merged
GregHolmes merged 1 commit intomainfrom
AIT-140-Guide-documentation-citations-and-source-annotations
Feb 24, 2026
Merged

docs: add citation guides for OpenAI and Anthropic#3146
GregHolmes merged 1 commit intomainfrom
AIT-140-Guide-documentation-citations-and-source-annotations

Conversation

@GregHolmes
Copy link
Contributor

Add two new AI Transport guides demonstrating how to attach source citations to AI responses using Ably message annotations:

  • openai-citations.mdx: Attach citations from OpenAI web search
  • anthropic-citations.mdx: Attach citations from Anthropic documents

Both guides cover:

  • Enabling message annotations via channel rules
  • Publishing responses and citations to Ably
  • Subscribing to citation summaries and individual citations
  • Combining citations with streaming responses

@GregHolmes GregHolmes self-assigned this Jan 22, 2026
@GregHolmes GregHolmes added the review-app Create a Heroku review app label Jan 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AIT-140-Guide-documentation-citations-and-source-annotations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ably-ci ably-ci temporarily deployed to ably-docs-ait-140-guide-aj312o January 22, 2026 15:28 Inactive
@zknill zknill self-requested a review February 12, 2026 16:11
}

// Publish the AI response message
const { serials: [msgSerial] } = await channel.publish('response', fullText);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does fullText come from? we never actually call processResponse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1cb5e6b

fullText is further up.
I've removed the initiation of processResponse, console logged and then call processResponse when it's created in a later step.

Comment on lines 341 to 363
await channel.subscribe((message) => {
switch (message.action) {
case 'message.create':
console.log('\n[New response]');
console.log('Serial:', message.serial);
console.log('Content:', message.data);
responses.set(message.serial, { content: message.data, citations: [] });
break;

case 'message.update':
// Handle streamed content updates
const response = responses.get(message.serial);
if (response) {
response.content = message.data;
console.log('\n[Response updated]');
console.log('Content:', message.data);
}
break;
}
});

// Subscribe to individual citation annotations
await channel.annotations.subscribe((annotation) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel.subscribe(...) isn't processing message.summary action, and channel.annotations.subscribe(...) is for raw annotations.

So this doesn't match the header: "Step 4: Subscribe to citation summaries " which references summaries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openapi guide has a different set of headers here that works better to fix this problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've aligned anthropic with the openai guide: 4dd9be4

// Create response with web search enabled
async function getOpenAIResponseWithCitations(question) {
const response = await openai.responses.create({
model: "gpt-4.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're using gpt-5 in the openai-message-per-response doc, lets just be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in this fixup: 7c06253

@GregHolmes GregHolmes force-pushed the AIT-140-Guide-documentation-citations-and-source-annotations branch from 854d3df to f555560 Compare February 23, 2026 16:20
Comment on lines 5 to 14
---

This guide shows you how to attach source citations to AI responses from Anthropic's [Messages API](https://docs.anthropic.com/en/api/messages) using Ably [message annotations](/docs/messages/annotations). When Anthropic provides citations from documents or search results, you can publish them as annotations on Ably messages, enabling clients to display source references alongside AI responses in realtime.

Using Ably to distribute citations enables you to separate citation metadata from response content, display citation summaries updated in realtime, and retrieve detailed citation data on demand.

<Aside data-type="further-reading">
To learn more about the citations pattern and how message annotations work, see the [citations](/docs/ai-transport/messaging/citations) documentation.
</Aside>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know / have an idea on why you would want to include citations? Like.. why would I care about adding annotations to a message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, missing a key bit here. Why use citations. I've updated the intro text: adbef67

@GregHolmes GregHolmes force-pushed the AIT-140-Guide-documentation-citations-and-source-annotations branch from 7c06253 to 91b3c04 Compare February 24, 2026 10:32

This guide shows you how to attach source citations to AI responses from Anthropic's [Messages API](https://docs.anthropic.com/en/api/messages) using Ably [message annotations](/docs/messages/annotations). When Anthropic provides citations from documents or search results, you can publish them as annotations on Ably messages, enabling clients to display source references alongside AI responses in realtime.

Attaching citations to AI responses enables your users to verify claims against original sources, explore topics in depth, and properly attribute content creators. For enterprises, citations provide explicit traceability between LLM responses and the information sources that were consulted when generating them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's "enterprises" got to do with it?

This reads a bit janky, around "verify claims against original sources", etc.

Copy link
Contributor

@zknill zknill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 shippo 🚢

@GregHolmes GregHolmes added review-app Create a Heroku review app and removed review-app Create a Heroku review app labels Feb 24, 2026
@ably-ci ably-ci temporarily deployed to ably-docs-ait-140-guide-ixhqtq February 24, 2026 10:57 Inactive
Add two new AI Transport guides demonstrating how to attach source
citations to AI responses using Ably message annotations:

- openai-citations.mdx: Attach citations from OpenAI web search
- anthropic-citations.mdx: Attach citations from Anthropic documents

Both guides cover:
- Enabling message annotations via channel rules
- Publishing responses and citations to Ably
- Subscribing to citation summaries and individual citations
- Combining citations with streaming responses
@GregHolmes GregHolmes force-pushed the AIT-140-Guide-documentation-citations-and-source-annotations branch from 3033daf to 340e08f Compare February 24, 2026 10:57
@GregHolmes GregHolmes temporarily deployed to ably-docs-ait-140-guide-ixhqtq February 24, 2026 10:58 Inactive
@GregHolmes GregHolmes merged commit 4be74ac into main Feb 24, 2026
7 checks passed
@GregHolmes GregHolmes deleted the AIT-140-Guide-documentation-citations-and-source-annotations branch February 24, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-code-assisted review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

3 participants