@assistant-ui/mcp-docs-server 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.docs/organized/code-examples/with-ag-ui.md +172 -1633
  2. package/.docs/organized/code-examples/with-ai-sdk-v6.md +42 -1640
  3. package/.docs/organized/code-examples/with-assistant-transport.md +40 -1743
  4. package/.docs/organized/code-examples/with-cloud.md +71 -1745
  5. package/.docs/organized/code-examples/with-custom-thread-list.md +87 -1723
  6. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +70 -1637
  7. package/.docs/organized/code-examples/with-external-store.md +67 -1624
  8. package/.docs/organized/code-examples/with-ffmpeg.md +71 -1629
  9. package/.docs/organized/code-examples/with-langgraph.md +95 -1893
  10. package/.docs/organized/code-examples/with-parent-id-grouping.md +57 -1654
  11. package/.docs/organized/code-examples/with-react-hook-form.md +220 -2163
  12. package/.docs/organized/code-examples/with-react-router.md +66 -1318
  13. package/.docs/organized/code-examples/with-store.md +31 -31
  14. package/.docs/organized/code-examples/with-tanstack.md +77 -861
  15. package/.docs/organized/code-examples/with-tap-runtime.md +812 -0
  16. package/.docs/raw/docs/(docs)/cli.mdx +66 -0
  17. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -1
  18. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -1
  19. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +4 -4
  20. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +3 -3
  21. package/.docs/raw/docs/(docs)/devtools.mdx +0 -1
  22. package/.docs/raw/docs/(docs)/guides/attachments.mdx +2 -3
  23. package/.docs/raw/docs/(docs)/guides/context-api.mdx +117 -117
  24. package/.docs/raw/docs/(docs)/guides/suggestions.mdx +296 -0
  25. package/.docs/raw/docs/(docs)/guides/tools.mdx +336 -513
  26. package/.docs/raw/docs/(docs)/index.mdx +33 -410
  27. package/.docs/raw/docs/(docs)/installation.mdx +450 -0
  28. package/.docs/raw/docs/(docs)/llm.mdx +209 -0
  29. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -1
  30. package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -1
  31. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +48 -3
  32. package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -1
  33. package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -1
  34. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +9 -3
  35. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +20 -52
  36. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +16 -39
  37. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +49 -50
  38. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +3 -11
  39. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -3
  40. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -1
  41. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +5 -16
  42. package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -1
  43. package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -1
  44. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +1 -2
  45. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -1
  46. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +152 -0
  47. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -1
  48. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +1 -2
  49. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +1 -2
  50. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +28 -40
  51. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -1
  52. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +1 -2
  53. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +2 -3
  54. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +1 -2
  55. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +1 -2
  56. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -1
  57. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -1
  58. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +1 -2
  59. package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -1
  60. package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +5 -5
  61. package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -1
  62. package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -1
  63. package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +207 -33
  64. package/.docs/raw/docs/(reference)/react-compatibility.mdx +0 -1
  65. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -1
  66. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +0 -1
  67. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -1
  68. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +118 -0
  69. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +198 -0
  70. package/.docs/raw/docs/runtimes/assistant-transport.mdx +3 -3
  71. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +5 -6
  72. package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -11
  73. package/.docs/raw/docs/runtimes/custom/local.mdx +43 -36
  74. package/.docs/raw/docs/runtimes/data-stream.mdx +35 -3
  75. package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -2
  76. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -1
  77. package/.docs/raw/docs/runtimes/langserve.mdx +0 -1
  78. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -1
  79. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -1
  80. package/.docs/raw/docs/ui/accordion.mdx +259 -0
  81. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -3
  82. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -3
  83. package/.docs/raw/docs/ui/attachment.mdx +0 -2
  84. package/.docs/raw/docs/ui/badge.mdx +138 -0
  85. package/.docs/raw/docs/ui/diff-viewer.mdx +279 -0
  86. package/.docs/raw/docs/ui/file.mdx +152 -0
  87. package/.docs/raw/docs/ui/image.mdx +100 -0
  88. package/.docs/raw/docs/ui/markdown.mdx +0 -1
  89. package/.docs/raw/docs/ui/mermaid.mdx +0 -1
  90. package/.docs/raw/docs/ui/model-selector.mdx +224 -0
  91. package/.docs/raw/docs/ui/part-grouping.mdx +4 -5
  92. package/.docs/raw/docs/ui/reasoning.mdx +6 -5
  93. package/.docs/raw/docs/ui/scrollbar.mdx +26 -9
  94. package/.docs/raw/docs/ui/select.mdx +245 -0
  95. package/.docs/raw/docs/ui/sources.mdx +6 -5
  96. package/.docs/raw/docs/ui/streamdown.mdx +348 -0
  97. package/.docs/raw/docs/ui/syntax-highlighting.mdx +8 -63
  98. package/.docs/raw/docs/ui/tabs.mdx +259 -0
  99. package/.docs/raw/docs/ui/thread-list.mdx +98 -16
  100. package/.docs/raw/docs/ui/thread.mdx +57 -73
  101. package/.docs/raw/docs/ui/tool-fallback.mdx +0 -1
  102. package/.docs/raw/docs/ui/tool-group.mdx +1 -3
  103. package/README.md +3 -3
  104. package/package.json +4 -4
  105. package/src/tools/tests/examples.test.ts +1 -1
  106. package/.docs/raw/docs/(docs)/about-assistantui.mdx +0 -54
  107. package/.docs/raw/docs/(docs)/mcp-docs-server.mdx +0 -321
  108. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +0 -219
@@ -7,11 +7,108 @@ description: Unified state API replaces individual context hooks.
7
7
 
8
8
  Version 0.12 introduces a complete rewrite of the state management system with a more consistent API.
9
9
 
10
+ ## Automatic Migration
11
+
12
+ We provide a codemod to automatically migrate your code:
13
+
14
+ ```bash
15
+ npx assistant-ui@latest upgrade
16
+ ```
17
+
18
+ This will automatically handle the hook renames and update your imports.
19
+
10
20
  ## Breaking Changes
11
21
 
12
- ### 1. Context Hooks Replaced with Unified State API
22
+ ### 1. Assistant API Hooks Renamed
23
+
24
+ The core hooks have been renamed for consistency and clarity:
25
+
26
+ - `useAssistantApi` → `useAui`
27
+ - `useAssistantState` → `useAuiState`
28
+ - `useAssistantEvent` → `useAuiEvent`
29
+
30
+ The variable naming convention has also changed from `api` to `aui`.
31
+
32
+ #### Migration
33
+
34
+ **Before:**
35
+
36
+ ```tsx
37
+ import {
38
+ useAssistantApi,
39
+ useAssistantState,
40
+ useAssistantEvent,
41
+ } from "@assistant-ui/react";
42
+
43
+ function MyComponent() {
44
+ const api = useAssistantApi();
45
+ const isRunning = useAssistantState(({ thread }) => thread.isRunning);
46
+
47
+ useAssistantEvent("thread.started", () => {
48
+ console.log("Thread started");
49
+ });
50
+
51
+ const handleSend = () => {
52
+ api.composer().send();
53
+ };
54
+
55
+ return <button onClick={handleSend}>Send</button>;
56
+ }
57
+ ```
58
+
59
+ **After:**
60
+
61
+ ```tsx
62
+ import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
63
+
64
+ function MyComponent() {
65
+ const aui = useAui();
66
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
67
+
68
+ useAuiEvent("thread.started", () => {
69
+ console.log("Thread started");
70
+ });
71
+
72
+ const handleSend = () => {
73
+ aui.composer().send();
74
+ };
75
+
76
+ return <button onClick={handleSend}>Send</button>;
77
+ }
78
+ ```
79
+
80
+ **Automatic Migration:**
81
+
82
+ Run the codemod to automatically update your code:
83
+
84
+ ```bash
85
+ npx assistant-ui@latest upgrade
86
+ ```
87
+
88
+ The codemod will:
89
+ - Rename all hook imports (`useAssistantApi` → `useAui`, etc.)
90
+ - Rename `const api = useAui()` declarations to `const aui = useAui()`
91
+ - Update all references to the `api` variable throughout your codebase
92
+ - Correctly handle scoping (won't rename `api` variables from other sources)
93
+
94
+ **Backwards Compatibility:**
95
+
96
+ The old names are still available as deprecated exports until v0.13:
13
97
 
14
- All individual context hooks have been replaced with a single `useAssistantState` hook and `useAssistantApi` for actions.
98
+ ```tsx
99
+ // Still works, but deprecated
100
+ import {
101
+ useAssistantApi,
102
+ useAssistantState,
103
+ useAssistantEvent,
104
+ } from "@assistant-ui/react";
105
+
106
+ const api = useAssistantApi(); // deprecated but functional
107
+ ```
108
+
109
+ ### 2. Context Hooks Replaced with Unified State API
110
+
111
+ All individual context hooks have been replaced with a single `useAuiState` hook and `useAui` for actions.
15
112
 
16
113
  #### What changed
17
114
 
@@ -19,30 +116,30 @@ The following hooks have been removed:
19
116
 
20
117
  **Removed Hooks:**
21
118
 
22
- - `useMessageUtils` → Use `useAssistantState(({ message }) => message.isHovering)` / `useAssistantState(({ message }) => message.isCopied)`
23
- - `useMessageUtilsStore` → Use `useAssistantApi()` with `api.message().setIsHovering()` / `api.message().setIsCopied()`
24
- - `useToolUIs` → Use `useAssistantState(({ tools }) => tools)` and `useAssistantApi()` with `api.tools()`
25
- - `useToolUIsStore` → Use `useAssistantApi()` with `api.tools()`
119
+ - `useMessageUtils` → Use `useAuiState(({ message }) => message.isHovering)` / `useAuiState(({ message }) => message.isCopied)`
120
+ - `useMessageUtilsStore` → Use `useAui()` with `aui.message().setIsHovering()` / `aui.message().setIsCopied()`
121
+ - `useToolUIs` → Use `useAuiState(({ tools }) => tools)` and `useAui()` with `aui.tools()`
122
+ - `useToolUIsStore` → Use `useAui()` with `aui.tools()`
26
123
 
27
124
  **Deprecated Hooks:**
28
125
 
29
- - `useAssistantRuntime` → Use `useAssistantApi()`
30
- - `useThread` → Use `useAssistantState(({ thread }) => thread)`
31
- - `useThreadRuntime` → Use `useAssistantApi()` with `api.thread()`
32
- - `useMessage` → Use `useAssistantState(({ message }) => message)`
33
- - `useMessageRuntime` → Use `useAssistantApi()` with `api.message()`
34
- - `useComposer` → Use `useAssistantState(({ composer }) => composer)`
35
- - `useComposerRuntime` → Use `useAssistantApi()` with `api.composer()`
36
- - `useEditComposer` → Use `useAssistantState(({ message }) => message.composer)`
37
- - `useThreadListItem` → Use `useAssistantState(({ threadListItem }) => threadListItem)`
38
- - `useThreadListItemRuntime` → Use `useAssistantApi()` with `api.threadListItem()`
39
- - `useMessagePart` → Use `useAssistantState(({ part }) => part)`
40
- - `useMessagePartRuntime` → Use `useAssistantApi()` with `api.part()`
41
- - `useAttachment` → Use `useAssistantState(({ attachment }) => attachment)`
42
- - `useAttachmentRuntime` → Use `useAssistantApi()` with `api.attachment()`
43
- - `useThreadModelContext` / `useThreadModelConfig` → Use `useAssistantState(({ thread }) => thread.modelContext)`
44
- - `useThreadComposer` → Use `useAssistantState(({ thread }) => thread.composer)`
45
- - `useThreadList` → Use `useAssistantState(({ threads }) => threads)`
126
+ - `useAssistantRuntime` → Use `useAui()`
127
+ - `useThread` → Use `useAuiState(({ thread }) => thread)`
128
+ - `useThreadRuntime` → Use `useAui()` with `aui.thread()`
129
+ - `useMessage` → Use `useAuiState(({ message }) => message)`
130
+ - `useMessageRuntime` → Use `useAui()` with `aui.message()`
131
+ - `useComposer` → Use `useAuiState(({ composer }) => composer)`
132
+ - `useComposerRuntime` → Use `useAui()` with `aui.composer()`
133
+ - `useEditComposer` → Use `useAuiState(({ message }) => message.composer)`
134
+ - `useThreadListItem` → Use `useAuiState(({ threadListItem }) => threadListItem)`
135
+ - `useThreadListItemRuntime` → Use `useAui()` with `aui.threadListItem()`
136
+ - `useMessagePart` → Use `useAuiState(({ part }) => part)`
137
+ - `useMessagePartRuntime` → Use `useAui()` with `aui.part()`
138
+ - `useAttachment` → Use `useAuiState(({ attachment }) => attachment)`
139
+ - `useAttachmentRuntime` → Use `useAui()` with `aui.attachment()`
140
+ - `useThreadModelContext` / `useThreadModelConfig` → Use `useAuiState(({ thread }) => thread.modelContext)`
141
+ - `useThreadComposer` → Use `useAuiState(({ thread }) => thread.composer)`
142
+ - `useThreadList` → Use `useAuiState(({ threads }) => threads)`
46
143
 
47
144
  #### Migration Examples
48
145
 
@@ -89,34 +186,111 @@ function MyComponent() {
89
186
  **After:**
90
187
 
91
188
  ```tsx
92
- import { useAssistantState, useAssistantApi } from "@assistant-ui/react";
189
+ import { useAuiState, useAui } from "@assistant-ui/react";
93
190
 
94
191
  function MyComponent() {
95
192
  // Reading state - all through single hook
96
- const messages = useAssistantState(({ thread }) => thread.messages);
97
- const isRunning = useAssistantState(({ thread }) => thread.isRunning);
98
- const composerText = useAssistantState(({ composer }) => composer.text);
99
- const messageRole = useAssistantState(({ message }) => message.role);
193
+ const messages = useAuiState(({ thread }) => thread.messages);
194
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
195
+ const composerText = useAuiState(({ composer }) => composer.text);
196
+ const messageRole = useAuiState(({ message }) => message.role);
100
197
 
101
- // Using API for actions
102
- const api = useAssistantApi();
198
+ // Using client for actions
199
+ const aui = useAui();
103
200
 
104
201
  const handleSend = () => {
105
- api.composer().send();
202
+ aui.composer().send();
106
203
  };
107
204
 
108
205
  const handleReload = () => {
109
- api.message().reload();
206
+ aui.message().reload();
110
207
  };
111
208
 
112
209
  const handleCancel = () => {
113
- api.thread().cancelRun();
210
+ aui.thread().cancelRun();
114
211
  };
115
212
 
116
213
  return null;
117
214
  }
118
215
  ```
119
216
 
217
+ ### 3. Event Names Changed to camelCase
218
+
219
+ Event names used with `useAuiEvent` have been standardized to use camelCase instead of kebab-case.
220
+
221
+ #### What changed
222
+
223
+ The following event names have been updated:
224
+
225
+ | Old Name (kebab-case) | New Name (camelCase) |
226
+ | ----------------------------------- | ---------------------------------- |
227
+ | `thread.run-start` | `thread.runStart` |
228
+ | `thread.run-end` | `thread.runEnd` |
229
+ | `thread.model-context-update` | `thread.modelContextUpdate` |
230
+ | `composer.attachment-add` | `composer.attachmentAdd` |
231
+ | `thread-list-item.switched-to` | `threadListItem.switchedTo` |
232
+ | `thread-list-item.switched-away` | `threadListItem.switchedAway` |
233
+
234
+ Events that remain unchanged:
235
+ - `thread.initialize`
236
+ - `composer.send`
237
+
238
+ #### Migration
239
+
240
+ **Before:**
241
+
242
+ ```tsx
243
+ import { useAuiEvent } from "@assistant-ui/react";
244
+
245
+ function MyComponent() {
246
+ useAuiEvent("thread.run-start", () => {
247
+ console.log("Thread started running");
248
+ });
249
+
250
+ useAuiEvent("thread.run-end", () => {
251
+ console.log("Thread finished running");
252
+ });
253
+
254
+ useAuiEvent("composer.attachment-add", () => {
255
+ console.log("Attachment added");
256
+ });
257
+
258
+ return null;
259
+ }
260
+ ```
261
+
262
+ **After:**
263
+
264
+ ```tsx
265
+ import { useAuiEvent } from "@assistant-ui/react";
266
+
267
+ function MyComponent() {
268
+ useAuiEvent("thread.runStart", () => {
269
+ console.log("Thread started running");
270
+ });
271
+
272
+ useAuiEvent("thread.runEnd", () => {
273
+ console.log("Thread finished running");
274
+ });
275
+
276
+ useAuiEvent("composer.attachmentAdd", () => {
277
+ console.log("Attachment added");
278
+ });
279
+
280
+ return null;
281
+ }
282
+ ```
283
+
284
+ **Automatic Migration:**
285
+
286
+ Run the codemod to automatically update event names:
287
+
288
+ ```bash
289
+ npx assistant-ui@latest upgrade
290
+ ```
291
+
292
+ The codemod will automatically replace all occurrences of the old kebab-case event names with their new camelCase equivalents.
293
+
120
294
  ## Getting Help
121
295
 
122
296
  If you encounter issues during migration:
@@ -3,7 +3,6 @@ title: Using old React versions
3
3
  description: Compatibility notes for React 18, 17, and 16.
4
4
  ---
5
5
 
6
- import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
7
6
 
8
7
  <Callout type="warning" title="Older React Versions">
9
8
  Older React versions are not continuously tested. If you encounter any issues
@@ -3,7 +3,6 @@ title: Chat History for AI SDK
3
3
  description: Integrate cloud persistence and thread management with Vercel AI SDK.
4
4
  ---
5
5
 
6
- import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
7
6
 
8
7
  ## Overview
9
8
 
@@ -3,7 +3,6 @@ title: Chat History for LangGraph Cloud
3
3
  description: Integrate cloud persistence and thread management with LangGraph Cloud.
4
4
  ---
5
5
 
6
- import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
7
6
 
8
7
  ## Overview
9
8
 
@@ -3,7 +3,6 @@ title: AI SDK v4 (Legacy)
3
3
  description: Legacy integration for Vercel AI SDK v4 using data stream runtime.
4
4
  ---
5
5
 
6
- import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
7
6
 
8
7
  ## Overview
9
8
 
@@ -0,0 +1,118 @@
1
+ ---
2
+ title: AI SDK v5 (Legacy)
3
+ description: Integrate Vercel AI SDK v5 with useChatRuntime for streaming chat.
4
+ ---
5
+
6
+ <Callout type="error">
7
+ AI SDK v5 is no longer supported. The `@assistant-ui/react-ai-sdk` package now requires AI SDK v6+.
8
+ Please upgrade to [AI SDK v6](/docs/runtimes/ai-sdk/v6).
9
+ </Callout>
10
+
11
+ ## Overview
12
+
13
+ This documentation is preserved for reference. For new projects, use [AI SDK v6](/docs/runtimes/ai-sdk/v6).
14
+
15
+ ## Getting Started
16
+
17
+ <Steps>
18
+ <Step>
19
+ ### Create a Next.js project
20
+
21
+ ```sh
22
+ npx create-next-app@latest my-app
23
+ cd my-app
24
+ ```
25
+
26
+ </Step>
27
+ <Step>
28
+
29
+ ### Install AI SDK v5 and `@assistant-ui/react`
30
+
31
+ ```sh
32
+ npm install @assistant-ui/react @assistant-ui/react-ai-sdk@0.x ai@^5 @ai-sdk/openai@^1 zod
33
+ ```
34
+
35
+ </Step>
36
+ <Step>
37
+
38
+ ### Setup a backend route under `/api/chat`
39
+
40
+ `@/app/api/chat/route.ts`
41
+
42
+ ```tsx
43
+ import { openai } from "@ai-sdk/openai";
44
+ import { streamText, tool } from "ai";
45
+ import type { Message } from "ai";
46
+ import { z } from "zod";
47
+
48
+ export const maxDuration = 30;
49
+
50
+ export async function POST(req: Request) {
51
+ const { messages }: { messages: Message[] } = await req.json();
52
+
53
+ const result = streamText({
54
+ model: openai("gpt-4o"),
55
+ messages,
56
+ tools: {
57
+ get_current_weather: tool({
58
+ description: "Get the current weather",
59
+ parameters: z.object({
60
+ city: z.string(),
61
+ }),
62
+ execute: async ({ city }) => {
63
+ return `The weather in ${city} is sunny`;
64
+ },
65
+ }),
66
+ },
67
+ });
68
+
69
+ return result.toDataStreamResponse();
70
+ }
71
+ ```
72
+
73
+ </Step>
74
+ <Step>
75
+
76
+ ### Setup the frontend
77
+
78
+ `@/app/page.tsx`
79
+
80
+ ```tsx
81
+ "use client";
82
+
83
+ import { Thread } from "@/components/assistant-ui/thread";
84
+ import { AssistantRuntimeProvider } from "@assistant-ui/react";
85
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
86
+
87
+ export default function Home() {
88
+ const runtime = useChatRuntime({
89
+ api: "/api/chat",
90
+ });
91
+
92
+ return (
93
+ <AssistantRuntimeProvider runtime={runtime}>
94
+ <div className="h-full">
95
+ <Thread />
96
+ </div>
97
+ </AssistantRuntimeProvider>
98
+ );
99
+ }
100
+ ```
101
+
102
+ </Step>
103
+ </Steps>
104
+
105
+ ## Key Differences from v6
106
+
107
+ | Feature | v5 | v6 |
108
+ |---------|----|----|
109
+ | **ai package** | `ai@^5` | `ai@^6` |
110
+ | **@ai-sdk/openai** | `@ai-sdk/openai@^1` | `@ai-sdk/openai@^3` |
111
+ | **Message type** | `Message` | `UIMessage` |
112
+ | **convertToModelMessages** | Sync | Async (`await`) |
113
+ | **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
114
+ | **Response** | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
115
+
116
+ ## Migration to v6
117
+
118
+ See the [AI SDK v6 documentation](/docs/runtimes/ai-sdk/v6) for the latest integration guide.
@@ -0,0 +1,198 @@
1
+ ---
2
+ title: AI SDK v6
3
+ description: Integrate Vercel AI SDK v6 with assistant-ui for streaming chat.
4
+ ---
5
+
6
+
7
+ ## Overview
8
+
9
+ Integration with the Vercel AI SDK v6 using the `useChatRuntime` hook from `@assistant-ui/react-ai-sdk`.
10
+
11
+ ## Getting Started
12
+
13
+ <Steps>
14
+ <Step>
15
+ ### Create a Next.js project
16
+
17
+ ```sh
18
+ npx create-next-app@latest my-app
19
+ cd my-app
20
+ ```
21
+
22
+ </Step>
23
+ <Step>
24
+
25
+ ### Install dependencies
26
+
27
+ <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
28
+
29
+ </Step>
30
+ <Step>
31
+
32
+ ### Setup a backend route under `/api/chat`
33
+
34
+ `@/app/api/chat/route.ts`
35
+
36
+ ```tsx
37
+ import { openai } from "@ai-sdk/openai";
38
+ import {
39
+ streamText,
40
+ convertToModelMessages,
41
+ tool,
42
+ zodSchema,
43
+ } from "ai";
44
+ import type { UIMessage } from "ai";
45
+ import { z } from "zod";
46
+
47
+ export const maxDuration = 30;
48
+
49
+ export async function POST(req: Request) {
50
+ const { messages }: { messages: UIMessage[] } = await req.json();
51
+
52
+ const result = streamText({
53
+ model: openai("gpt-4o"),
54
+ messages: await convertToModelMessages(messages), // Note: async in v6
55
+ tools: {
56
+ get_current_weather: tool({
57
+ description: "Get the current weather",
58
+ inputSchema: zodSchema(
59
+ z.object({
60
+ city: z.string(),
61
+ }),
62
+ ),
63
+ execute: async ({ city }) => {
64
+ return `The weather in ${city} is sunny`;
65
+ },
66
+ }),
67
+ },
68
+ });
69
+
70
+ return result.toUIMessageStreamResponse();
71
+ }
72
+ ```
73
+
74
+ </Step>
75
+ <Step>
76
+
77
+ ### Setup the frontend
78
+
79
+ `@/app/page.tsx`
80
+
81
+ ```tsx
82
+ "use client";
83
+
84
+ import { Thread } from "@/components/assistant-ui/thread";
85
+ import { AssistantRuntimeProvider } from "@assistant-ui/react";
86
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
87
+
88
+ export default function Home() {
89
+ const runtime = useChatRuntime();
90
+
91
+ return (
92
+ <AssistantRuntimeProvider runtime={runtime}>
93
+ <div className="h-full">
94
+ <Thread />
95
+ </div>
96
+ </AssistantRuntimeProvider>
97
+ );
98
+ }
99
+ ```
100
+
101
+ </Step>
102
+ </Steps>
103
+
104
+ ## Key Changes from v5
105
+
106
+ | Feature | v5 | v6 |
107
+ |---------|----|----|
108
+ | **ai package** | `ai@^5` | `ai@^6` |
109
+ | **@ai-sdk/react** | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
110
+ | **convertToModelMessages** | Sync | Async (`await`) |
111
+ | **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
112
+
113
+ ## API Reference
114
+
115
+ ### useChatRuntime
116
+
117
+ Creates a runtime integrated with AI SDK's `useChat` hook.
118
+
119
+ ```tsx
120
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
121
+
122
+ const runtime = useChatRuntime({
123
+ api: "/api/chat", // optional, defaults to "/api/chat"
124
+ });
125
+ ```
126
+
127
+ ### Custom API URL
128
+
129
+ ```tsx
130
+ const runtime = useChatRuntime({
131
+ api: "/my-custom-api/chat",
132
+ });
133
+ ```
134
+
135
+ ### Forwarding System Messages and Frontend Tools
136
+
137
+ Use `AssistantChatTransport` to automatically forward system messages and frontend tools to your backend:
138
+
139
+ ```tsx
140
+ "use client";
141
+
142
+ import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
143
+
144
+ const runtime = useChatRuntime({
145
+ transport: new AssistantChatTransport({
146
+ api: "/api/chat",
147
+ }),
148
+ });
149
+ ```
150
+
151
+ Backend route with system/tools forwarding:
152
+
153
+ ```tsx
154
+ import { openai } from "@ai-sdk/openai";
155
+ import { streamText, convertToModelMessages, zodSchema } from "ai";
156
+ import type { UIMessage } from "ai";
157
+ import { frontendTools } from "@assistant-ui/react-ai-sdk";
158
+
159
+ export async function POST(req: Request) {
160
+ const {
161
+ messages,
162
+ system,
163
+ tools,
164
+ }: {
165
+ messages: UIMessage[];
166
+ system?: string;
167
+ tools?: any;
168
+ } = await req.json();
169
+
170
+ const result = streamText({
171
+ model: openai("gpt-4o"),
172
+ system,
173
+ messages: await convertToModelMessages(messages),
174
+ tools: {
175
+ ...frontendTools(tools),
176
+ // your backend tools...
177
+ },
178
+ });
179
+
180
+ return result.toUIMessageStreamResponse();
181
+ }
182
+ ```
183
+
184
+ ### useAISDKRuntime (Advanced)
185
+
186
+ For advanced use cases where you need direct access to the `useChat` hook:
187
+
188
+ ```tsx
189
+ import { useChat } from "@ai-sdk/react";
190
+ import { useAISDKRuntime } from "@assistant-ui/react-ai-sdk";
191
+
192
+ const chat = useChat();
193
+ const runtime = useAISDKRuntime(chat);
194
+ ```
195
+
196
+ ## Example
197
+
198
+ For a complete example, check out the [AI SDK v6 example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-ai-sdk-v6) in our repository.
@@ -503,7 +503,7 @@ To enable resumability, you need to:
503
503
  2. Use the `unstable_resumeRun` API to resume a conversation
504
504
 
505
505
  ```typescript
506
- import { useAssistantApi } from "@assistant-ui/react";
506
+ import { useAui } from "@assistant-ui/react";
507
507
 
508
508
  const runtime = useAssistantTransportRuntime({
509
509
  // ... other options
@@ -513,8 +513,8 @@ const runtime = useAssistantTransportRuntime({
513
513
  });
514
514
 
515
515
  // Typically called on thread switch or mount to check if sync server has anything to resume
516
- const api = useAssistantApi();
517
- api.thread().unstable_resumeRun({
516
+ const aui = useAui();
517
+ aui.thread().unstable_resumeRun({
518
518
  parentId: null, // Ignored (will be removed in a future version)
519
519
  });
520
520
  ```
@@ -3,7 +3,6 @@ title: Custom Thread List
3
3
  description: Plug a custom thread database for multi-thread persistence.
4
4
  ---
5
5
 
6
- import { ParametersTable } from "@/components/docs/tables/ParametersTable";
7
6
 
8
7
  ## Overview
9
8
 
@@ -222,26 +221,26 @@ When the hook mounts it calls `list()` on your adapter, hydrates existing thread
222
221
  When implementing a custom history adapter, you must await thread initialization before saving messages. Failing to do so can cause the first message to be lost due to a race condition.
223
222
  </Callout>
224
223
 
225
- If you're building a history adapter that persists messages to your own database, use `api.threadListItem().initialize()` to ensure the thread is fully initialized before saving:
224
+ If you're building a history adapter that persists messages to your own database, use `aui.threadListItem().initialize()` to ensure the thread is fully initialized before saving:
226
225
 
227
226
  ```tsx
228
- import { useAssistantApi } from "@assistant-ui/react";
227
+ import { useAui } from "@assistant-ui/react";
229
228
 
230
229
  // Inside your unstable_Provider component
231
- const api = useAssistantApi();
230
+ const aui = useAui();
232
231
 
233
232
  const history = useMemo<ThreadHistoryAdapter>(
234
233
  () => ({
235
234
  async append(message) {
236
235
  // Wait for initialization to complete and get the remoteId
237
- const { remoteId } = await api.threadListItem().initialize();
236
+ const { remoteId } = await aui.threadListItem().initialize();
238
237
 
239
238
  // Now safe to save the message using the remoteId
240
239
  await saveMessageToDatabase(remoteId, message);
241
240
  },
242
241
  // ...
243
242
  }),
244
- [api],
243
+ [aui],
245
244
  );
246
245
  ```
247
246