@assistant-ui/mcp-docs-server 0.1.29 → 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 (214) hide show
  1. package/.docs/organized/code-examples/waterfall.md +15 -7
  2. package/.docs/organized/code-examples/with-a2a.md +9 -21
  3. package/.docs/organized/code-examples/with-ag-ui.md +11 -8
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +10 -10
  5. package/.docs/organized/code-examples/with-artifacts.md +12 -10
  6. package/.docs/organized/code-examples/with-assistant-transport.md +11 -12
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +83 -54
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
  9. package/.docs/organized/code-examples/with-cloud.md +9 -10
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +61 -16
  11. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -12
  12. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +13 -13
  13. package/.docs/organized/code-examples/with-expo.md +25 -21
  14. package/.docs/organized/code-examples/with-external-store.md +8 -8
  15. package/.docs/organized/code-examples/with-ffmpeg.md +17 -12
  16. package/.docs/organized/code-examples/with-generative-ui.md +9 -9
  17. package/.docs/organized/code-examples/with-google-adk.md +8 -8
  18. package/.docs/organized/code-examples/with-heat-graph.md +5 -5
  19. package/.docs/organized/code-examples/with-interactables.md +10 -25
  20. package/.docs/organized/code-examples/with-langchain.md +437 -0
  21. package/.docs/organized/code-examples/with-langgraph.md +16 -16
  22. package/.docs/organized/code-examples/with-livekit.md +18 -13
  23. package/.docs/organized/code-examples/with-opencode.md +105 -62
  24. package/.docs/organized/code-examples/with-parent-id-grouping.md +10 -10
  25. package/.docs/organized/code-examples/with-react-hook-form.md +220 -148
  26. package/.docs/organized/code-examples/with-react-ink.md +2 -2
  27. package/.docs/organized/code-examples/with-react-router.md +12 -12
  28. package/.docs/organized/code-examples/with-store.md +8 -5
  29. package/.docs/organized/code-examples/with-tanstack.md +10 -10
  30. package/.docs/organized/code-examples/with-tap-runtime.md +10 -6
  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 +80 -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/composer.mdx +149 -40
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
  60. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
  61. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
  62. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
  63. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
  64. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +9 -0
  65. package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
  66. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +231 -3
  67. package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
  68. package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
  69. package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
  70. package/.docs/raw/docs/guides/branching.mdx +76 -0
  71. package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
  72. package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
  73. package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
  74. package/.docs/raw/docs/guides/editing.mdx +102 -0
  75. package/.docs/raw/docs/guides/index.mdx +103 -0
  76. package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
  77. package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
  78. package/.docs/raw/docs/guides/mentions.mdx +520 -0
  79. package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
  80. package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
  81. package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
  82. package/.docs/raw/docs/guides/slash-commands.mdx +361 -0
  83. package/.docs/raw/docs/guides/speech.mdx +156 -0
  84. package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
  85. package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
  86. package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
  87. package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
  88. package/.docs/raw/docs/ink/index.mdx +1 -3
  89. package/.docs/raw/docs/ink/migration.mdx +1 -3
  90. package/.docs/raw/docs/ink/primitives.mdx +37 -1
  91. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
  92. package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
  93. package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
  94. package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
  95. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
  96. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
  97. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
  98. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
  99. package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
  100. package/.docs/raw/docs/integrations/index.mdx +173 -0
  101. package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
  102. package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
  103. package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
  104. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
  105. package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
  106. package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
  107. package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
  108. package/.docs/raw/docs/primitives/attachment.mdx +1 -0
  109. package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
  110. package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
  111. package/.docs/raw/docs/primitives/composer.mdx +96 -63
  112. package/.docs/raw/docs/primitives/error.mdx +1 -0
  113. package/.docs/raw/docs/primitives/index.mdx +2 -1
  114. package/.docs/raw/docs/primitives/message.mdx +68 -5
  115. package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
  116. package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
  117. package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
  118. package/.docs/raw/docs/primitives/thread.mdx +16 -13
  119. package/.docs/raw/docs/react-native/index.mdx +1 -3
  120. package/.docs/raw/docs/react-native/migration.mdx +1 -3
  121. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
  122. package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
  123. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
  124. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
  125. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
  126. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
  127. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
  128. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
  129. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
  130. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +365 -101
  131. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
  132. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
  133. package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
  134. package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
  135. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
  136. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
  137. package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
  138. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
  139. package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
  140. package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
  141. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
  142. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
  143. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
  144. package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
  145. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
  146. package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
  147. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
  148. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
  149. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
  150. package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
  151. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
  152. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
  153. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
  154. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
  155. package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
  156. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
  157. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +74 -198
  158. package/.docs/raw/docs/ui/accordion.mdx +1 -0
  159. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
  160. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
  161. package/.docs/raw/docs/ui/attachment.mdx +1 -0
  162. package/.docs/raw/docs/ui/badge.mdx +1 -0
  163. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +200 -0
  164. package/.docs/raw/docs/ui/context-display.mdx +1 -0
  165. package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
  166. package/.docs/raw/docs/ui/directive-text.mdx +114 -0
  167. package/.docs/raw/docs/ui/file.mdx +1 -0
  168. package/.docs/raw/docs/ui/image.mdx +1 -0
  169. package/.docs/raw/docs/ui/markdown.mdx +2 -14
  170. package/.docs/raw/docs/ui/mermaid.mdx +1 -0
  171. package/.docs/raw/docs/ui/message-timing.mdx +3 -2
  172. package/.docs/raw/docs/ui/model-selector.mdx +1 -0
  173. package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
  174. package/.docs/raw/docs/ui/quote.mdx +1 -0
  175. package/.docs/raw/docs/ui/reasoning.mdx +69 -32
  176. package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
  177. package/.docs/raw/docs/ui/select.mdx +1 -0
  178. package/.docs/raw/docs/ui/sources.mdx +1 -0
  179. package/.docs/raw/docs/ui/streamdown.mdx +1 -0
  180. package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
  181. package/.docs/raw/docs/ui/tabs.mdx +1 -0
  182. package/.docs/raw/docs/ui/thread-list.mdx +17 -0
  183. package/.docs/raw/docs/ui/thread.mdx +56 -1
  184. package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
  185. package/.docs/raw/docs/ui/tool-group.mdx +39 -11
  186. package/.docs/raw/docs/ui/voice.mdx +1 -0
  187. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
  188. package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
  189. package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
  190. package/dist/utils/logger.js +1 -1
  191. package/dist/utils/logger.js.map +1 -1
  192. package/package.json +4 -4
  193. package/src/tools/tests/path-traversal.test.ts +1 -1
  194. package/src/utils/logger.ts +1 -1
  195. package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
  196. package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
  197. package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
  198. package/.docs/raw/docs/(docs)/guides/mentions.mdx +0 -406
  199. package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +0 -275
  200. package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
  201. package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
  202. package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
  203. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -268
  204. package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
  205. package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
  206. package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
  207. package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
  208. package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -607
  209. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
  210. package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
  211. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
  212. package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
  213. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
  214. package/.docs/raw/docs/ui/mention.mdx +0 -168
@@ -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,115 +328,133 @@ 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
-
157
- ## Key Changes from v5
158
-
159
- | Feature | v5 | v6 |
160
- |---------|----|----|
161
- | **ai package** | `ai@^5` | `ai@^6` |
162
- | **@ai-sdk/react** | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
163
- | **convertToModelMessages** | Sync | Async (`await`) |
164
- | **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
165
353
 
166
- ## API Reference
354
+ `getThreadMessageTokenUsage(message)` returns per-message usage if you need to show it inline.
167
355
 
168
- ### useChatRuntime
356
+ ## Attachments
169
357
 
170
- Creates a runtime integrated with AI SDK's `useChat` hook.
358
+ Attachments work through the standard [attachment adapter](/docs/runtimes/concepts/adapters#attachment-adapter). Pass it via `useChatRuntime`:
171
359
 
172
360
  ```tsx
173
- import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
361
+ const runtime = useChatRuntime({
362
+ adapters: { attachments: myAttachmentAdapter },
363
+ });
364
+ ```
174
365
 
175
- const runtime = useChatRuntime();
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
+ };
176
381
  ```
177
382
 
178
- ### Custom API URL
383
+ For images, use `{ type: "image", image: <data url or remote url> }`. AI SDK will pass these to providers that accept multimodal content.
179
384
 
180
- To use a different endpoint, pass a custom `AssistantChatTransport`:
385
+ ## Persisting chat history
386
+
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`.
388
+
389
+ <Callout type="warn">
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.
391
+ </Callout>
392
+
393
+ <Callout type="info">
394
+ For server-side cloud persistence with zero adapter code, see the [AssistantCloud integration](/docs/cloud/ai-sdk-assistant-ui).
395
+ </Callout>
181
396
 
182
397
  ```tsx
183
- import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
398
+ "use client";
184
399
 
185
- const runtime = useChatRuntime({
186
- transport: new AssistantChatTransport({
187
- api: "/my-custom-api/chat",
400
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
401
+ import type { ThreadHistoryAdapter } from "@assistant-ui/react";
402
+
403
+ const historyAdapter: ThreadHistoryAdapter = {
404
+ // Required by the type — unused by useChatRuntime.
405
+ async load() {
406
+ return { headId: null, messages: [] };
407
+ },
408
+ async append() {},
409
+
410
+ // fmt encodes UIMessage <-> storage rows (ai-sdk/v6 format).
411
+ withFormat: (fmt) => ({
412
+ async load() {
413
+ const rows = await fetch("/api/history").then((r) => r.json());
414
+ return { messages: rows.map(fmt.decode) };
415
+ },
416
+ async append(item) {
417
+ await fetch("/api/history", {
418
+ method: "POST",
419
+ body: JSON.stringify({
420
+ id: fmt.getId(item.message),
421
+ parent_id: item.parentId,
422
+ format: fmt.format,
423
+ content: fmt.encode(item),
424
+ }),
425
+ });
426
+ },
188
427
  }),
189
- });
428
+ };
429
+
430
+ function Chat() {
431
+ const runtime = useChatRuntime({ adapters: { history: historyAdapter } });
432
+ // ...
433
+ }
190
434
  ```
191
435
 
192
- ### System Messages and Frontend Tools
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.
193
437
 
194
- `AssistantChatTransport` (used by default) automatically forwards system messages and frontend tools to your backend. To consume them, update your backend route:
438
+ ## Custom transport
195
439
 
196
- Backend route with system/tools forwarding:
440
+ `AssistantChatTransport` is the default. To point at a non-default endpoint, instantiate it with a custom `api`:
197
441
 
198
442
  ```tsx
199
- import { openai } from "@ai-sdk/openai";
200
- import { streamText, convertToModelMessages, zodSchema } from "ai";
201
- import type { UIMessage } from "ai";
202
- import { frontendTools } from "@assistant-ui/react-ai-sdk";
203
-
204
- export async function POST(req: Request) {
205
- const {
206
- messages,
207
- system,
208
- tools,
209
- }: {
210
- messages: UIMessage[];
211
- system?: string;
212
- tools?: any;
213
- } = await req.json();
214
-
215
- const result = streamText({
216
- model: openai("gpt-4o"),
217
- system,
218
- messages: await convertToModelMessages(messages),
219
- tools: {
220
- ...frontendTools(tools),
221
- // your backend tools...
222
- },
223
- });
443
+ import {
444
+ useChatRuntime,
445
+ AssistantChatTransport,
446
+ } from "@assistant-ui/react-ai-sdk";
224
447
 
225
- return result.toUIMessageStreamResponse();
226
- }
448
+ const runtime = useChatRuntime({
449
+ transport: new AssistantChatTransport({ api: "/my-custom-api/chat" }),
450
+ });
227
451
  ```
228
452
 
229
- ### useAISDKRuntime (Advanced)
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.
454
+
455
+ ## Advanced: useAISDKRuntime
230
456
 
231
- 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`:
232
458
 
233
459
  ```tsx
234
460
  import { useChat } from "@ai-sdk/react";
@@ -238,6 +464,44 @@ const chat = useChat();
238
464
  const runtime = useAISDKRuntime(chat);
239
465
  ```
240
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
+
241
490
  ## Example
242
491
 
243
- 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>