Connect the Vercel AI SDK to a React chat UI via assistant-ui — useChat hooks, custom transports, frontend tools, attachments, multi-step agents, and token usage.
@assistant-ui/ai-sdk integrates assistant-ui with the Vercel AI SDK. It covers useChat flows, custom transports, frontend tools, attachments, quote context, multi-step agents, token usage, and cloud persistence.
Where it fits
@assistant-ui/ai-sdk wraps the AI SDK's useChat hook and exposes it as an assistant-ui runtime. The runtime owns conversation state on the client; your /api/chat route calls streamText and returns its result as a UI message stream with toUIMessageStreamResponse(). Everything else (tools, attachments, observability, gateways, custom persistence) layers on top of this base.
When to use it
AI SDK is the default choice for new projects on Next.js, Remix, or any framework with a Node-compatible API route. Pick it when:
- You want a single direct path from the chat UI to your model with the smallest possible code surface.
- You will compose with a framework like Mastra, an observability tool, an LLM gateway, or tools through MCP, all of which assume an AI SDK route.
- You want first-party
frontendTools, attachments, multi-step tool calls, token-usage metadata, and persisted history viawithFormat.
If you need streaming agent state (subgraph events, generative UI messages), look at LangGraph instead. If you have a different protocol-shaped backend (A2A, AG-UI, OpenCode), see pick a runtime.
Pick a version
| AI SDK | Runtime package | Docs |
|---|---|---|
ai@^7 + @ai-sdk/react@^4 | @assistant-ui/ai-sdk (latest) | v7 (current) |
ai@^6 + @ai-sdk/react@^3 | @assistant-ui/react-ai-sdk@1.3.40 | v6 (legacy) |
ai@^5 + @ai-sdk/react@^2 | @assistant-ui/react-ai-sdk@1.1.21 | v5 (legacy) |
ai@^4 | @assistant-ui/react-data-stream | v4 (legacy) |
@assistant-ui/ai-sdk targets AI SDK v7 and needs ai@^7.0.101. New projects start there. v6, v5, and v4 are documented for projects that have not migrated yet; all have known compatibility gaps and receive no new features.
For reload-safe streaming (persist an in-flight response so the client can reconnect), see Resumable Streams.
Choosing useChatRuntime vs useAISDKRuntime
Both ship in the same package.
useChatRuntime(recommended) wraps the AI SDK'suseChathook and adds cloud thread support, the standard adapter slots, andAssistantChatTransport(which forwards system messages and frontend tools by default). Use this unless you have a reason not to.useAISDKRuntimeis a lower-level hook that takes an existinguseChatinstance you control directly. Use it when you need to share the chat instance with non-assistant-ui code or wire in a custom transport that does not inherit fromAssistantChatTransport.