Skip to content

Document AI chat streaming with PowerSync - #711

Merged
bean1352 merged 13 commits into
mainfrom
docs/ai-chat-streaming
Oct 30, 2026
Merged

bean1352 merged 13 commits into
mainfrom
docs/ai-chat-streaming

Conversation

@bean1352

Copy link
Copy Markdown
Contributor

Adds a guide on streaming AI chat replies with PowerSync. It covers the two ways I can think of to do it, writing the reply to the database as it generates or streaming it over SSE and saving it once, with the trade-offs of each. It also covers smoothing the text on the client.

The guide links to the new AI chat demo (powersync-ja/powersync-js#1152), which I've also added to the Examples page. Those links won't work until the demo PR is merged.

AI Disclosure

I had Claude Opus 5.5 generate the bulk of the content based off the demo, I manually reviewed and edited it.

@mintlify

mintlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
powersync 🟢 Ready View Preview Oct 30, 2026, 7:33 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@bean1352
bean1352 marked this pull request as ready for review October 27, 2026 13:50
@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Reviewed the added AI Chat Streaming guide against the writing standards and cross-checked its technical claims (write/claim-ID conditions, 100 ms flush interval, 150 char/s and 1 s smoothing caps, 100 char/s worker pacing, the 1,600-character/9-write/160-write example, billing and compaction claims, and all internal links/anchors) against powersync-ja/powersync-js#1152 and the existing docs. No issues found; the changes pass review.

@bean1352
bean1352 marked this pull request as ready for review October 27, 2026 14:13
@bean1352
bean1352 requested a review from benitav October 27, 2026 14:13
Comment thread intro/examples.mdx Resolved
@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Reviewed the diff and verified claims against the merged demo (powersync-ja/powersync-js#1152). Left 3 inline comments: a correctness gap in the retry/claim write condition, and two stale TODOs now that the demo PR has merged. Note: Vale and pnpm check:links could not be run in this environment, so their results aren't reflected here.

@cahofmeyr cahofmeyr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I find the way that the introductory section is written confusing: The title of the page talks about AI Chat Streaming: "Stream AI chat replies to clients while the model generates them" but the content after that starts talking about the fact that chats can be treated as ordinary rows in the database, so they are durable, i.e. when you reload, they're still there. So that is about more than just streaming while generating. I suggest changing the title of the page to something like: "AI Chat Use Cases" or something similar, and then clearly explain the different concepts involved and the benefits that PowerSync provides in the different areas:

  1. Chats can be stored as rows in the database, providing potential benefits like durability, cross-device, multi-user collaboration, etc. (these are just rough notes – need to improve the wording and explanation)
  2. If you want to incrementally stream responses to clients while they're generating, here are the techniques that we have tested and what PowerSync gives you: ... . This builds on the idea of point 1, i.e. you could do point 1 without doing point 2 at all.

The page also has significant AI smell which makes it not read well. I would rewrite it to remove AI smells.

@bean1352
bean1352 marked this pull request as draft October 28, 2026 06:57
@bean1352
bean1352 marked this pull request as ready for review October 28, 2026 11:35
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
@bean1352

Copy link
Copy Markdown
Contributor Author

I find the way that the introductory section is written confusing: The title of the page talks about AI Chat Streaming: "Stream AI chat replies to clients while the model generates them" but the content after that starts talking about the fact that chats can be treated as ordinary rows in the database, so they are durable, i.e. when you reload, they're still there. So that is about more than just streaming while generating. I suggest changing the title of the page to something like: "AI Chat Use Cases" or something similar, and then clearly explain the different concepts involved and the benefits that PowerSync provides in the different areas:

  1. Chats can be stored as rows in the database, providing potential benefits like durability, cross-device, multi-user collaboration, etc. (these are just rough notes – need to improve the wording and explanation)
  2. If you want to incrementally stream responses to clients while they're generating, here are the techniques that we have tested and what PowerSync gives you: ... . This builds on the idea of point 1, i.e. you could do point 1 without doing point 2 at all.

The page also has significant AI smell which makes it not read well. I would rewrite it to remove AI smells.

I do agree that it didn't read well, apologies for that. I've rewritten it and made it more like a guide instead.

I renamed the page to "AI Chat" and the content is split in two now.

  1. Storing chats as synced rows
  2. Streaming text while the model generates it (via PowerSync and over SSE)

I also cut out a lot of the demo specific detail.

Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
Comment thread client-sdks/advanced/ai-chat.mdx Resolved
@bean1352
bean1352 merged commit bd02813 into main Oct 30, 2026
8 of 10 checks passed
@bean1352
bean1352 deleted the docs/ai-chat-streaming branch October 30, 2026 14:06

This branch was successfully deployed

1 active deployment
staging — 2c9b07b1 Deployed Oct 30, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants