@assistant-ui/mcp-docs-server 0.1.30 → 0.1.31

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 (208) hide show
  1. package/.docs/organized/code-examples/waterfall.md +1 -1
  2. package/.docs/organized/code-examples/with-a2a.md +2 -2
  3. package/.docs/organized/code-examples/with-ag-ui.md +3 -3
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +5 -5
  5. package/.docs/organized/code-examples/with-artifacts.md +5 -5
  6. package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +79 -50
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
  9. package/.docs/organized/code-examples/with-cloud.md +4 -4
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +56 -11
  11. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +7 -7
  12. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
  13. package/.docs/organized/code-examples/with-expo.md +16 -16
  14. package/.docs/organized/code-examples/with-external-store.md +2 -2
  15. package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
  16. package/.docs/organized/code-examples/with-generative-ui.md +5 -5
  17. package/.docs/organized/code-examples/with-google-adk.md +4 -4
  18. package/.docs/organized/code-examples/with-heat-graph.md +1 -1
  19. package/.docs/organized/code-examples/with-interactables.md +5 -5
  20. package/.docs/organized/code-examples/with-langchain.md +3 -3
  21. package/.docs/organized/code-examples/with-langgraph.md +3 -3
  22. package/.docs/organized/code-examples/with-livekit.md +8 -8
  23. package/.docs/organized/code-examples/with-opencode.md +99 -54
  24. package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
  25. package/.docs/organized/code-examples/with-react-hook-form.md +5 -5
  26. package/.docs/organized/code-examples/with-react-ink.md +1 -1
  27. package/.docs/organized/code-examples/with-react-router.md +8 -8
  28. package/.docs/organized/code-examples/with-store.md +1 -1
  29. package/.docs/organized/code-examples/with-tanstack.md +5 -5
  30. package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
  31. package/.docs/raw/docs/(docs)/cli.mdx +2 -1
  32. package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
  33. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
  34. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
  35. package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
  36. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
  37. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
  38. package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
  39. package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
  40. package/.docs/raw/docs/(docs)/index.mdx +1 -0
  41. package/.docs/raw/docs/(docs)/installation.mdx +1 -0
  42. package/.docs/raw/docs/(docs)/rtl.mdx +1 -0
  43. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
  44. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
  45. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
  46. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
  47. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
  49. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
  50. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
  51. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
  52. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
  53. package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
  54. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
  55. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
  60. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
  61. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
  62. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +5 -0
  63. package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
  64. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +230 -2
  65. package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
  66. package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
  67. package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
  68. package/.docs/raw/docs/guides/branching.mdx +76 -0
  69. package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
  70. package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
  71. package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
  72. package/.docs/raw/docs/guides/editing.mdx +102 -0
  73. package/.docs/raw/docs/guides/index.mdx +103 -0
  74. package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
  75. package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
  76. package/.docs/raw/docs/{(docs)/guides → guides}/mentions.mdx +61 -86
  77. package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
  78. package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
  79. package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
  80. package/.docs/raw/docs/{(docs)/guides → guides}/slash-commands.mdx +103 -37
  81. package/.docs/raw/docs/guides/speech.mdx +156 -0
  82. package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
  83. package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
  84. package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
  85. package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
  86. package/.docs/raw/docs/ink/index.mdx +1 -3
  87. package/.docs/raw/docs/ink/migration.mdx +1 -3
  88. package/.docs/raw/docs/ink/primitives.mdx +37 -1
  89. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
  90. package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
  91. package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
  92. package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
  93. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
  94. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
  95. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
  96. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
  97. package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
  98. package/.docs/raw/docs/integrations/index.mdx +173 -0
  99. package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
  100. package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
  101. package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
  102. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
  103. package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
  104. package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
  105. package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
  106. package/.docs/raw/docs/primitives/attachment.mdx +1 -0
  107. package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
  108. package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
  109. package/.docs/raw/docs/primitives/composer.mdx +2 -1
  110. package/.docs/raw/docs/primitives/error.mdx +1 -0
  111. package/.docs/raw/docs/primitives/index.mdx +2 -1
  112. package/.docs/raw/docs/primitives/message.mdx +68 -5
  113. package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
  114. package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
  115. package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
  116. package/.docs/raw/docs/primitives/thread.mdx +16 -13
  117. package/.docs/raw/docs/react-native/index.mdx +1 -3
  118. package/.docs/raw/docs/react-native/migration.mdx +1 -3
  119. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
  120. package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
  121. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
  122. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
  123. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
  124. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
  125. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
  126. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
  127. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
  128. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +330 -123
  129. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
  130. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
  131. package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
  132. package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
  133. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
  134. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
  135. package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
  136. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
  137. package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
  138. package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
  139. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
  140. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
  141. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
  142. package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
  143. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
  144. package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
  145. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
  146. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
  147. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
  148. package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
  149. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
  150. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
  151. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
  152. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
  153. package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
  154. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
  155. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +71 -203
  156. package/.docs/raw/docs/ui/accordion.mdx +1 -0
  157. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
  158. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
  159. package/.docs/raw/docs/ui/attachment.mdx +1 -0
  160. package/.docs/raw/docs/ui/badge.mdx +1 -0
  161. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +1 -0
  162. package/.docs/raw/docs/ui/context-display.mdx +1 -0
  163. package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
  164. package/.docs/raw/docs/ui/directive-text.mdx +1 -0
  165. package/.docs/raw/docs/ui/file.mdx +1 -0
  166. package/.docs/raw/docs/ui/image.mdx +1 -0
  167. package/.docs/raw/docs/ui/markdown.mdx +2 -14
  168. package/.docs/raw/docs/ui/mermaid.mdx +1 -0
  169. package/.docs/raw/docs/ui/message-timing.mdx +3 -2
  170. package/.docs/raw/docs/ui/model-selector.mdx +1 -0
  171. package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
  172. package/.docs/raw/docs/ui/quote.mdx +1 -0
  173. package/.docs/raw/docs/ui/reasoning.mdx +66 -33
  174. package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
  175. package/.docs/raw/docs/ui/select.mdx +1 -0
  176. package/.docs/raw/docs/ui/sources.mdx +1 -0
  177. package/.docs/raw/docs/ui/streamdown.mdx +1 -0
  178. package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
  179. package/.docs/raw/docs/ui/tabs.mdx +1 -0
  180. package/.docs/raw/docs/ui/thread-list.mdx +17 -0
  181. package/.docs/raw/docs/ui/thread.mdx +56 -1
  182. package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
  183. package/.docs/raw/docs/ui/tool-group.mdx +39 -11
  184. package/.docs/raw/docs/ui/voice.mdx +1 -0
  185. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
  186. package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
  187. package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
  188. package/package.json +3 -3
  189. package/src/tools/tests/path-traversal.test.ts +1 -1
  190. package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
  191. package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
  192. package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
  193. package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
  194. package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
  195. package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
  196. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -314
  197. package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
  198. package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
  199. package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
  200. package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
  201. package/.docs/raw/docs/runtimes/langchain/comparison.mdx +0 -60
  202. package/.docs/raw/docs/runtimes/langchain/index.mdx +0 -210
  203. package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -699
  204. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
  205. package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
  206. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
  207. package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
  208. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
@@ -3,37 +3,75 @@ title: AI SDK v6
3
3
  description: Integrate Vercel AI SDK v6 with assistant-ui for streaming chat.
4
4
  ---
5
5
 
6
+ Current-version integration. Requires `ai@^6` and `@ai-sdk/react@^3`. For older versions see the [overview](/docs/runtimes/ai-sdk).
6
7
 
7
- ## Overview
8
+ ## Quickstart
8
9
 
9
- Integration with the Vercel AI SDK v6 using the `useChatRuntime` hook from `@assistant-ui/react-ai-sdk`.
10
+ <Steps>
11
+ <Step>
10
12
 
11
- ## Getting Started
13
+ ### Create a project
12
14
 
13
- <Steps>
14
- <Step>
15
- ### Create a Next.js project
15
+ <PlatformTabs>
16
+ <Tab value="React">
16
17
 
17
18
  ```sh
18
19
  npx create-next-app@latest my-app
19
20
  cd my-app
20
21
  ```
21
22
 
22
- </Step>
23
- <Step>
23
+ </Tab>
24
+ <Tab value="React Native">
25
+
26
+ ```sh
27
+ npx create-expo-app@latest my-app
28
+ cd my-app
29
+ ```
30
+
31
+ </Tab>
32
+ <Tab value="React Ink">
33
+
34
+ ```sh
35
+ mkdir my-app
36
+ cd my-app
37
+ npm init -y
38
+ ```
39
+
40
+ </Tab>
41
+ </PlatformTabs>
42
+
43
+ </Step>
44
+ <Step>
24
45
 
25
46
  ### Install dependencies
26
47
 
48
+ <PlatformTabs>
49
+ <Tab value="React">
50
+
27
51
  <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
28
52
 
29
- </Step>
30
- <Step>
53
+ </Tab>
54
+ <Tab value="React Native">
31
55
 
32
- ### Setup a backend route under `/api/chat`
56
+ <InstallCommand expo={["@assistant-ui/react-native", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
33
57
 
34
- `@/app/api/chat/route.ts`
58
+ </Tab>
59
+ <Tab value="React Ink">
35
60
 
36
- ```tsx
61
+ <InstallCommand npm={["@assistant-ui/react-ink", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod", "ink", "react"]} />
62
+
63
+ </Tab>
64
+ </PlatformTabs>
65
+
66
+ </Step>
67
+ <Step>
68
+
69
+ ### Set up the backend route
70
+
71
+ For React Native and Ink, host this route in a separate backend project and
72
+ point the client runtime at its absolute URL.
73
+
74
+ ```ts title="@/app/api/chat/route.ts"
37
75
  import { openai } from "@ai-sdk/openai";
38
76
  import {
39
77
  streamText,
@@ -50,16 +88,12 @@ export async function POST(req: Request) {
50
88
  const { messages }: { messages: UIMessage[] } = await req.json();
51
89
 
52
90
  const result = streamText({
53
- model: openai("gpt-4o"),
54
- messages: await convertToModelMessages(messages), // Note: async in v6
91
+ model: openai("gpt-5.4-mini"),
92
+ messages: await convertToModelMessages(messages), // async in v6
55
93
  tools: {
56
94
  get_current_weather: tool({
57
95
  description: "Get the current weather",
58
- inputSchema: zodSchema(
59
- z.object({
60
- city: z.string(),
61
- }),
62
- ),
96
+ inputSchema: zodSchema(z.object({ city: z.string() })),
63
97
  execute: async ({ city }) => {
64
98
  return `The weather in ${city} is sunny`;
65
99
  },
@@ -71,14 +105,15 @@ export async function POST(req: Request) {
71
105
  }
72
106
  ```
73
107
 
74
- </Step>
75
- <Step>
108
+ </Step>
109
+ <Step>
76
110
 
77
- ### Setup the frontend
111
+ ### Set up the frontend
78
112
 
79
- `@/app/page.tsx`
113
+ <PlatformTabs>
114
+ <Tab value="React">
80
115
 
81
- ```tsx
116
+ ```tsx title="@/app/page.tsx"
82
117
  "use client";
83
118
 
84
119
  import { Thread } from "@/components/assistant-ui/thread";
@@ -87,7 +122,6 @@ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
87
122
 
88
123
  export default function Home() {
89
124
  const runtime = useChatRuntime();
90
-
91
125
  return (
92
126
  <AssistantRuntimeProvider runtime={runtime}>
93
127
  <div className="h-full">
@@ -98,18 +132,192 @@ export default function Home() {
98
132
  }
99
133
  ```
100
134
 
101
- </Step>
135
+ </Tab>
136
+ <Tab value="React Native">
137
+
138
+ ```tsx title="app/index.tsx"
139
+ import { AssistantRuntimeProvider } from "@assistant-ui/react-native";
140
+ import {
141
+ AssistantChatTransport,
142
+ useChatRuntime,
143
+ } from "@assistant-ui/react-ai-sdk";
144
+ import { View } from "react-native";
145
+ import { Thread } from "@/components/assistant-ui/thread";
146
+
147
+ const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";
148
+
149
+ export default function Home() {
150
+ const runtime = useChatRuntime({
151
+ transport: new AssistantChatTransport({
152
+ api: `${API_URL}/api/chat`,
153
+ }),
154
+ });
155
+ return (
156
+ <AssistantRuntimeProvider runtime={runtime}>
157
+ <View style={{ flex: 1 }}>
158
+ <Thread />
159
+ </View>
160
+ </AssistantRuntimeProvider>
161
+ );
162
+ }
163
+ ```
164
+
165
+ </Tab>
166
+ <Tab value="React Ink">
167
+
168
+ ```tsx title="app.tsx"
169
+ import { AssistantRuntimeProvider } from "@assistant-ui/react-ink";
170
+ import {
171
+ AssistantChatTransport,
172
+ useChatRuntime,
173
+ } from "@assistant-ui/react-ai-sdk";
174
+ import { Box } from "ink";
175
+ import { Thread } from "./components/thread.js";
176
+
177
+ export function App() {
178
+ const runtime = useChatRuntime({
179
+ transport: new AssistantChatTransport({
180
+ api: "http://localhost:3000/api/chat",
181
+ }),
182
+ });
183
+ return (
184
+ <AssistantRuntimeProvider runtime={runtime}>
185
+ <Box flexDirection="column">
186
+ <Thread />
187
+ </Box>
188
+ </AssistantRuntimeProvider>
189
+ );
190
+ }
191
+ ```
192
+
193
+ </Tab>
194
+ </PlatformTabs>
195
+
196
+ </Step>
197
+ <Step>
198
+
199
+ ### Set up UI components
200
+
201
+ <PlatformTabs>
202
+ <Tab value="React">
203
+
204
+ Follow the [UI Components guide](/docs/ui/thread) to wire up the Thread, composer, and supporting primitives.
205
+
206
+ </Tab>
207
+ <Tab value="React Native">
208
+
209
+ Follow the [React Native setup](/docs/react-native) to add a native Thread, composer, and supporting primitives.
210
+
211
+ </Tab>
212
+ <Tab value="React Ink">
213
+
214
+ Follow the [Ink setup](/docs/ink) to add a terminal Thread, composer, and supporting primitives.
215
+
216
+ </Tab>
217
+ </PlatformTabs>
218
+
219
+ </Step>
102
220
  </Steps>
103
221
 
104
- ## Tracking Token Usage
222
+ ## Frontend tools and system messages
105
223
 
106
- assistant-ui exports a `useThreadTokenUsage` hook to access thread-level token usage on the client.
107
- <Steps>
108
- <Step>
109
- Use `messageMetadata` in your Next.js route to attach `usage` from `finish` and `modelId` from `finish-step`.
110
- ```tsx
224
+ `AssistantChatTransport` (used by default) forwards system messages and frontend tools to your backend on every request. Consume them with `frontendTools`:
225
+
226
+ ```ts title="@/app/api/chat/route.ts"
227
+ import { openai } from "@ai-sdk/openai";
228
+ import { streamText, convertToModelMessages, zodSchema } from "ai";
229
+ import type { UIMessage } from "ai";
230
+ import { frontendTools } from "@assistant-ui/react-ai-sdk";
231
+
232
+ export async function POST(req: Request) {
233
+ const {
234
+ messages,
235
+ system,
236
+ tools,
237
+ }: {
238
+ messages: UIMessage[];
239
+ system?: string;
240
+ tools?: any;
241
+ } = await req.json();
242
+
243
+ const result = streamText({
244
+ model: openai("gpt-5.4-mini"),
245
+ system,
246
+ messages: await convertToModelMessages(messages),
247
+ tools: {
248
+ ...frontendTools(tools),
249
+ // your backend tools...
250
+ },
251
+ });
252
+
253
+ return result.toUIMessageStreamResponse();
254
+ }
255
+ ```
256
+
257
+ Frontend tools are registered through `useAui` (see the [tools guide](/docs/guides/tools)) and serialized for the backend via `frontendTools`.
258
+
259
+ ## Multi-step tool calls
260
+
261
+ AI SDK v6 supports running multiple tool-call rounds in a single request via `stopWhen`. Use `stepCountIs(N)` to cap iterations:
262
+
263
+ ```ts title="@/app/api/chat/route.ts"
264
+ import { openai } from "@ai-sdk/openai";
265
+ import {
266
+ streamText,
267
+ convertToModelMessages,
268
+ stepCountIs,
269
+ } from "ai";
270
+
271
+ export async function POST(req: Request) {
272
+ const { messages } = await req.json();
273
+
274
+ const result = streamText({
275
+ model: openai("gpt-5.4-mini"),
276
+ messages: await convertToModelMessages(messages),
277
+ tools: {
278
+ /* ... */
279
+ },
280
+ stopWhen: stepCountIs(10), // cap at 10 tool-call iterations
281
+ });
282
+
283
+ return result.toUIMessageStreamResponse();
284
+ }
285
+ ```
286
+
287
+ Without a `stopWhen`, AI SDK runs a single inference step. Set `stepCountIs` (or one of AI SDK's other stop conditions) when your tools chain multiple calls.
288
+
289
+ ## Quote context
290
+
291
+ assistant-ui's composer can attach quote metadata to user messages (e.g. when the user selects text and clicks "Quote"). On the server, `injectQuoteContext` flattens that metadata into a markdown blockquote prefix so the LLM sees the quoted text:
292
+
293
+ ```ts title="@/app/api/chat/route.ts"
294
+ import {
295
+ streamText,
296
+ convertToModelMessages,
297
+ } from "ai";
298
+ import { injectQuoteContext } from "@assistant-ui/react-ai-sdk";
299
+ import { openai } from "@ai-sdk/openai";
300
+
301
+ export async function POST(req: Request) {
302
+ const { messages } = await req.json();
303
+ const result = streamText({
304
+ model: openai("gpt-5.4-mini"),
305
+ messages: await convertToModelMessages(injectQuoteContext(messages)),
306
+ });
307
+ return result.toUIMessageStreamResponse();
308
+ }
309
+ ```
310
+
311
+ `injectQuoteContext` is idempotent: if the blockquote prefix is already present, it is not duplicated.
312
+
313
+ ## Token usage
314
+
315
+ `useThreadTokenUsage` exposes thread-level token usage on the client. Attach `usage` and `modelId` via `messageMetadata` on the server:
316
+
317
+ ```ts title="@/app/api/chat/route.ts"
111
318
  import { streamText, convertToModelMessages } from "ai";
112
319
  import { frontendTools } from "@assistant-ui/react-ai-sdk";
320
+
113
321
  export async function POST(req: Request) {
114
322
  const { messages, tools, config } = await req.json();
115
323
  const result = streamText({
@@ -120,54 +328,72 @@ export async function POST(req: Request) {
120
328
  return result.toUIMessageStreamResponse({
121
329
  messageMetadata: ({ part }) => {
122
330
  if (part.type === "finish") {
123
- return {
124
- usage: part.totalUsage,
125
- };
331
+ return { usage: part.totalUsage };
126
332
  }
127
333
  if (part.type === "finish-step") {
128
- return {
129
- modelId: part.response.modelId,
130
- };
334
+ return { modelId: part.response.modelId };
131
335
  }
132
336
  return undefined;
133
337
  },
134
338
  });
135
339
  }
136
340
  ```
137
- </Step>
138
- <Step>
139
- Use `useThreadTokenUsage` to render token usage on the client.
140
341
 
141
- ```tsx
342
+ ```tsx title="@/components/TokenCounter.tsx"
142
343
  "use client";
143
344
 
144
345
  import { useThreadTokenUsage } from "@assistant-ui/react-ai-sdk";
145
346
 
146
347
  export function TokenCounter() {
147
348
  const usage = useThreadTokenUsage();
148
-
149
349
  if (!usage) return null;
150
-
151
350
  return <div>{usage.totalTokens} total tokens</div>;
152
351
  }
153
352
  ```
154
- </Step>
155
- </Steps>
156
353
 
157
- ## Persisting Chat History
354
+ `getThreadMessageTokenUsage(message)` returns per-message usage if you need to show it inline.
355
+
356
+ ## Attachments
357
+
358
+ Attachments work through the standard [attachment adapter](/docs/runtimes/concepts/adapters#attachment-adapter). Pass it via `useChatRuntime`:
359
+
360
+ ```tsx
361
+ const runtime = useChatRuntime({
362
+ adapters: { attachments: myAttachmentAdapter },
363
+ });
364
+ ```
365
+
366
+ Your attachment adapter's `send` should return `content` parts in the AI SDK shape, e.g. for files:
367
+
368
+ ```ts
369
+ return {
370
+ ...attachment,
371
+ status: { type: "complete" },
372
+ content: [
373
+ {
374
+ type: "file",
375
+ mimeType: attachment.contentType ?? "",
376
+ filename: attachment.name,
377
+ data: await getFileDataURL(attachment.file),
378
+ },
379
+ ],
380
+ };
381
+ ```
382
+
383
+ For images, use `{ type: "image", image: <data url or remote url> }`. AI SDK will pass these to providers that accept multimodal content.
384
+
385
+ ## Persisting chat history
158
386
 
159
387
  By default, messages live only in memory and reset on reload. To persist and restore history per thread, provide a `ThreadHistoryAdapter` via `adapters.history`.
160
388
 
161
389
  <Callout type="warn">
162
- The adapter **must** implement `withFormat`. `useChatRuntime` persists history through `withFormat(fmt)` so messages round-trip as AI SDK `UIMessage` objects. An adapter without `withFormat` throws at runtime — `load` / `append` on the top level are unused in the AI SDK path.
390
+ The adapter **must** implement `withFormat`. `useChatRuntime` persists history through `withFormat(fmt)` so messages round-trip as AI SDK `UIMessage` objects. An adapter without `withFormat` throws at runtime; `load` and `append` on the top level are unused in the AI SDK path.
163
391
  </Callout>
164
392
 
165
393
  <Callout type="info">
166
- For server-side cloud persistence with zero adapter code, see the [AssistantCloud integration](/docs/cloud/ai-sdk-assistant-ui).
394
+ For server-side cloud persistence with zero adapter code, see the [AssistantCloud integration](/docs/cloud/ai-sdk-assistant-ui).
167
395
  </Callout>
168
396
 
169
- ### Example
170
-
171
397
  ```tsx
172
398
  "use client";
173
399
 
@@ -181,7 +407,7 @@ const historyAdapter: ThreadHistoryAdapter = {
181
407
  },
182
408
  async append() {},
183
409
 
184
- // `fmt` encodes UIMessage ↔ storage rows (ai-sdk/v6 format).
410
+ // fmt encodes UIMessage <-> storage rows (ai-sdk/v6 format).
185
411
  withFormat: (fmt) => ({
186
412
  async load() {
187
413
  const rows = await fetch("/api/history").then((r) => r.json());
@@ -202,90 +428,33 @@ const historyAdapter: ThreadHistoryAdapter = {
202
428
  };
203
429
 
204
430
  function Chat() {
205
- const runtime = useChatRuntime({
206
- adapters: { history: historyAdapter },
207
- });
431
+ const runtime = useChatRuntime({ adapters: { history: historyAdapter } });
208
432
  // ...
209
433
  }
210
434
  ```
211
435
 
212
- Each persisted row follows `{ id, parent_id, format, content }`; `fmt.encode` produces the `content` payload and `fmt.decode` reverses it, so your backend never needs to know about `UIMessage` internals.
436
+ Each persisted row follows `{ id, parent_id, format, content }`. `fmt.encode` produces the `content` payload and `fmt.decode` reverses it, so your backend never needs to know about `UIMessage` internals.
213
437
 
214
- ## Key Changes from v5
438
+ ## Custom transport
215
439
 
216
- | Feature | v5 | v6 |
217
- |---------|----|----|
218
- | **ai package** | `ai@^5` | `ai@^6` |
219
- | **@ai-sdk/react** | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
220
- | **convertToModelMessages** | Sync | Async (`await`) |
221
- | **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
222
-
223
- ## API Reference
224
-
225
- ### useChatRuntime
226
-
227
- Creates a runtime integrated with AI SDK's `useChat` hook.
440
+ `AssistantChatTransport` is the default. To point at a non-default endpoint, instantiate it with a custom `api`:
228
441
 
229
442
  ```tsx
230
- import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
231
-
232
- const runtime = useChatRuntime();
233
- ```
234
-
235
- ### Custom API URL
236
-
237
- To use a different endpoint, pass a custom `AssistantChatTransport`:
238
-
239
- ```tsx
240
- import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
443
+ import {
444
+ useChatRuntime,
445
+ AssistantChatTransport,
446
+ } from "@assistant-ui/react-ai-sdk";
241
447
 
242
448
  const runtime = useChatRuntime({
243
- transport: new AssistantChatTransport({
244
- api: "/my-custom-api/chat",
245
- }),
449
+ transport: new AssistantChatTransport({ api: "/my-custom-api/chat" }),
246
450
  });
247
451
  ```
248
452
 
249
- ### System Messages and Frontend Tools
453
+ If you need a transport that does not inherit from `AssistantChatTransport`, you forfeit automatic system-message and frontend-tool forwarding; the transport is then a regular AI SDK `ChatTransport` and you control everything explicitly.
250
454
 
251
- `AssistantChatTransport` (used by default) automatically forwards system messages and frontend tools to your backend. To consume them, update your backend route:
455
+ ## Advanced: useAISDKRuntime
252
456
 
253
- Backend route with system/tools forwarding:
254
-
255
- ```tsx
256
- import { openai } from "@ai-sdk/openai";
257
- import { streamText, convertToModelMessages, zodSchema } from "ai";
258
- import type { UIMessage } from "ai";
259
- import { frontendTools } from "@assistant-ui/react-ai-sdk";
260
-
261
- export async function POST(req: Request) {
262
- const {
263
- messages,
264
- system,
265
- tools,
266
- }: {
267
- messages: UIMessage[];
268
- system?: string;
269
- tools?: any;
270
- } = await req.json();
271
-
272
- const result = streamText({
273
- model: openai("gpt-4o"),
274
- system,
275
- messages: await convertToModelMessages(messages),
276
- tools: {
277
- ...frontendTools(tools),
278
- // your backend tools...
279
- },
280
- });
281
-
282
- return result.toUIMessageStreamResponse();
283
- }
284
- ```
285
-
286
- ### useAISDKRuntime (Advanced)
287
-
288
- For advanced use cases where you need direct access to the `useChat` hook:
457
+ When you need direct access to the `useChat` instance (e.g. to share it with non-assistant-ui code), drop down to `useAISDKRuntime`:
289
458
 
290
459
  ```tsx
291
460
  import { useChat } from "@ai-sdk/react";
@@ -295,6 +464,44 @@ const chat = useChat();
295
464
  const runtime = useAISDKRuntime(chat);
296
465
  ```
297
466
 
467
+ `useAISDKRuntime` does not provide `cloud` or the higher-level adapter slots; those are part of `useChatRuntime`. If you need both your own `useChat` access AND cloud thread support, you generally want `useChatRuntime` and to read the chat state through assistant-ui hooks instead.
468
+
469
+ ## Adapter support
470
+
471
+ | Adapter | Supported via |
472
+ | --- | --- |
473
+ | Attachments | `adapters.attachments` |
474
+ | Speech | `adapters.speech` |
475
+ | Dictation | `adapters.dictation` |
476
+ | Feedback | `adapters.feedback` |
477
+ | History | `adapters.history` (must implement `withFormat`) |
478
+ | threadList | Via `cloud` (managed) or [RemoteThreadListRuntime](/docs/runtimes/concepts/threads) (custom DB) |
479
+
480
+ ## Key changes from v5
481
+
482
+ | Feature | v5 | v6 |
483
+ | --- | --- | --- |
484
+ | `ai` package | `ai@^5` | `ai@^6` |
485
+ | `@ai-sdk/react` | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
486
+ | `convertToModelMessages` | Sync | Async (`await`) |
487
+ | Tool schema | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
488
+ | Response | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
489
+
298
490
  ## Example
299
491
 
300
- 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.
492
+ [`examples/with-ai-sdk-v6`](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-ai-sdk-v6) shows a complete reference implementation.
493
+
494
+ ## Next
495
+
496
+ <Cards>
497
+ <Card
498
+ title="Adapters"
499
+ description="Attachments, speech, feedback, history, suggestions; one source of truth."
500
+ href="/docs/runtimes/concepts/adapters"
501
+ />
502
+ <Card
503
+ title="Threads"
504
+ description="Single-thread, AssistantCloud, custom thread list."
505
+ href="/docs/runtimes/concepts/threads"
506
+ />
507
+ </Cards>