assistant-ui
Always consult assistant-ui.com/llms.txt for the latest API.
React library for AI chat interfaces: unstyled primitives, a styled elements catalog, a runtime that adapts any backend, and optional cloud persistence. Current line is @assistant-ui/react 0.15.x on AI SDK v7 through @assistant-ui/ai-sdk.
References
When to Use
| Use Case |
Reach for |
| Chat UI in an afternoon |
npx assistant-ui@latest create, then the thread element |
| Full control over markup |
Primitives (ThreadPrimitive, ComposerPrimitive, MessagePrimitive) |
| Existing AI backend |
A runtime adapter (AI SDK, LangGraph, LangChain, ADK, A2A, AG-UI, Eve, OpenCode) or useLocalRuntime |
| Tools with UI |
"use generative" toolkits, tool UI, generative UI |
| Multi-thread apps |
Thread list elements plus Assistant Cloud or your own adapter |
| Copilots in an app |
Instructions, context, visible components, interactables |
| Mobile or terminal |
@assistant-ui/react-native, @assistant-ui/react-ink |
Architecture
┌──────────────────────────────────────────────────────────────┐
│ Elements (styled, copied into components/assistant-ui/) │
│ Primitives (unstyled, @assistant-ui/react) │
└───────────────────────────┬──────────────────────────────────┘
│ read state, call actions
┌───────────────────────────▼──────────────────────────────────┐
│ aui client: useAui, useAuiState, useAuiEvent, AuiIf │
│ scopes provided by AuiConfig through AssistantRuntimeProvider│
│ or AuiProvider (@assistant-ui/store on @assistant-ui/tap) │
└───────────────────────────┬──────────────────────────────────┘
│
┌───────────────────────────▼──────────────────────────────────┐
│ Runtime: AssistantRuntime → ThreadRuntime → MessageRuntime │
│ (@assistant-ui/core, framework neutral) │
└───────────────────────────┬──────────────────────────────────┘
│
┌───────────────────────────▼──────────────────────────────────┐
│ Adapters and backends: AI SDK · LangGraph · LangChain · ADK │
│ A2A · AG-UI · Eve · OpenCode · custom · Assistant Cloud │
└──────────────────────────────────────────────────────────────┘
Pick a Runtime
Vercel AI SDK?
├─ Yes → useChatRuntime from @assistant-ui/ai-sdk (recommended)
└─ No
├─ LangGraph server → useLangGraphRuntime (@assistant-ui/react-langgraph)
├─ LangChain / LangGraph useStream → useStreamRuntime (@assistant-ui/react-langchain)
├─ Google ADK → useAdkRuntime (@assistant-ui/react-google-adk)
├─ A2A protocol → useA2ARuntime (@assistant-ui/react-a2a)
├─ AG-UI protocol → useAgUiRuntime (@assistant-ui/react-ag-ui)
├─ Eve agents → useEveAgentRuntime (@assistant-ui/eve)
├─ OpenCode → useOpenCodeRuntime (@assistant-ui/react-opencode)
├─ Claude Managed Agents → useExternalStoreRuntime + useRemoteThreadListRuntime
├─ State already in Redux/Zustand/your store → useExternalStoreRuntime
├─ Custom endpoint speaking Assistant Transport → useAssistantTransportRuntime
└─ Any other custom API → useLocalRuntime with a ChatModelAdapter
Core Packages
| Package |
Purpose |
@assistant-ui/react |
Primitives, hooks, runtimes, provider |
@assistant-ui/ai-sdk |
AI SDK v7 integration (useChatRuntime, AssistantChatTransport, AISDKToolkit, frontendTools) |
@assistant-ui/core |
Framework-neutral runtime shared by React, React Native, Ink |
@assistant-ui/store |
AuiConfig, AuiProvider, useAui state layer |
@assistant-ui/react-markdown |
Markdown rendering (MarkdownTextPrimitive) |
assistant-stream |
Streaming protocol, encoders, resumable streams |
assistant-cloud |
Assistant Cloud client |
assistant-ui |
The CLI (create, init, add, update, upgrade, doctor, mcp, agent) |
@assistant-ui/react-ai-sdk re-exports @assistant-ui/ai-sdk for older installs; new code imports from @assistant-ui/ai-sdk. Styled components are not a package: npx assistant-ui@latest add thread copies them into components/assistant-ui/elements/. See ./references/packages.md for the full inventory.
Quick Start
"use client";
import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
export default function Chat() {
const runtime = useChatRuntime();
return (
<AssistantRuntimeProvider runtime={runtime}>
<Thread />
</AssistantRuntimeProvider>
);
}
useChatRuntime() posts to /api/chat through AssistantChatTransport, which also forwards frontend tools and system instructions. Pass new AssistantChatTransport({ api }) to change the endpoint.
State Access
Scope accessors on aui are properties; methods on a scope keep their parentheses. Selectors return one primitive or stable reference each.
import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
const aui = useAui();
aui.thread.append({ role: "user", content: [{ type: "text", text: "Hi" }] });
aui.thread.cancelRun();
aui.thread.composer().send();
aui.threads.switchToNewThread();
const messages = useAuiState((s) => s.thread.messages);
const isRunning = useAuiState((s) => s.thread.isRunning);
useAuiEvent("threads.selectionChanged", ({ threadId, previousThreadId }) => {});
Providing Scopes
Tools, suggestions, interactables, MCP managers, and other scopes are declared with AuiConfig and handed to the provider; useAui() takes no arguments.
import { AssistantRuntimeProvider, AuiConfig, Suggestions, Tools } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import toolkit from "./toolkit";
const runtime = useChatRuntime();
const config = AuiConfig({
tools: Tools({ toolkit }),
suggestions: Suggestions(["What can you do?", "Summarize this page"]),
});
<AssistantRuntimeProvider runtime={runtime} config={config}>{children}</AssistantRuntimeProvider>;
Nested scopes use <AuiProvider extends={useAui()} config={config}>; an isolated root uses extends={null}.
Related Skills
- setup -- CLI, templates, runtime adapters, platforms
- elements -- the styled component catalog and how to install and override it
- primitives -- unstyled building blocks and composer features
- runtime -- runtimes, the aui client, adapters, events
- tools -- toolkits, tool UI, approvals, MCP, WebMCP
- generative-ui -- the
present tool and component vocabularies
- streaming -- assistant-stream, transports, resumable streams
- cloud -- Assistant Cloud persistence and auth
- thread-list -- multi-thread management
- copilots -- grounding the assistant in your app
- markdown -- markdown, code, math, diagrams
- react-mcp -- user-managed MCP servers
- observability -- tracing and span visualization
- react-native -- Expo and React Native
- ink -- terminal chat with Ink
- update -- upgrades and migrations
1---2name: assistant-ui3description: Overview and router for assistant-ui, the React library for building AI chat interfaces from composable primitives and a styled elements catalog. Use for high-level, cross-cutting, or architecture questions: choosing packages, picking a runtime, or understanding the layers (elements, primitives, the aui client with AuiConfig and AuiProvider, the runtime, adapters) and the message model. Covers `@assistant-ui/react` 0.15.x, the framework-neutral `@assistant-ui/ai-sdk` integration for AI SDK v7 (`useChatRuntime`, `AssistantChatTransport`; `@assistant-ui/react-ai-sdk` re-exports it), `@assistant-ui/core`, `@assistant-ui/store`, `assistant-stream`, `assistant-cloud`, the adapters for LangGraph, LangChain, Google ADK, A2A, AG-UI, Eve, OpenCode, and Pi, and the platform bindings `@assistant-ui/react-native` and `@assistant-ui/react-ink`; `AssistantRuntimeProvider`; the primitives `ThreadPrimitive`, `MessagePrimitive`, `ComposerPrimitive`; the hooks `useAui`, `useAuiState`, `useAuiEvent`; and runtime selection acros4license: MIT5---6
7# assistant-ui
8
9**Always consult [assistant-ui.com/llms.txt](https://www.assistant-ui.com/llms.txt) for the latest API.**
10
11React library for AI chat interfaces: unstyled primitives, a styled elements catalog, a runtime that adapts any backend, and optional cloud persistence. Current line is `@assistant-ui/react` 0.15.x on AI SDK v7 through `@assistant-ui/ai-sdk`.
12
13## References
14
15- [./references/architecture.md](./references/architecture.md) -- layers, the aui client, data flow, message model
16- [./references/packages.md](./references/packages.md) -- every published package and when to install it
17
18## When to Use
19
20| Use Case | Reach for |
21|----------|-----------|
22| Chat UI in an afternoon | `npx assistant-ui@latest create`, then the `thread` element |
23| Full control over markup | Primitives (`ThreadPrimitive`, `ComposerPrimitive`, `MessagePrimitive`) |
24| Existing AI backend | A runtime adapter (AI SDK, LangGraph, LangChain, ADK, A2A, AG-UI, Eve, OpenCode) or `useLocalRuntime` |
25| Tools with UI | `"use generative"` toolkits, tool UI, generative UI |
26| Multi-thread apps | Thread list elements plus Assistant Cloud or your own adapter |
27| Copilots in an app | Instructions, context, visible components, interactables |
28| Mobile or terminal | `@assistant-ui/react-native`, `@assistant-ui/react-ink` |
29
30## Architecture
31
32```
33┌──────────────────────────────────────────────────────────────┐
34│ Elements (styled, copied into components/assistant-ui/) │
35│ Primitives (unstyled, @assistant-ui/react) │
36└───────────────────────────┬──────────────────────────────────┘
37 │ read state, call actions
38┌───────────────────────────▼──────────────────────────────────┐
39│ aui client: useAui, useAuiState, useAuiEvent, AuiIf │
40│ scopes provided by AuiConfig through AssistantRuntimeProvider│
41│ or AuiProvider (@assistant-ui/store on @assistant-ui/tap) │
42└───────────────────────────┬──────────────────────────────────┘
43 │
44┌───────────────────────────▼──────────────────────────────────┐
45│ Runtime: AssistantRuntime → ThreadRuntime → MessageRuntime │
46│ (@assistant-ui/core, framework neutral) │
47└───────────────────────────┬──────────────────────────────────┘
48 │
49┌───────────────────────────▼──────────────────────────────────┐
50│ Adapters and backends: AI SDK · LangGraph · LangChain · ADK │
51│ A2A · AG-UI · Eve · OpenCode · custom · Assistant Cloud │
52└──────────────────────────────────────────────────────────────┘
53```
54
55## Pick a Runtime
56
57```
58Vercel AI SDK?
59├─ Yes → useChatRuntime from @assistant-ui/ai-sdk (recommended)
60└─ No
61 ├─ LangGraph server → useLangGraphRuntime (@assistant-ui/react-langgraph)
62 ├─ LangChain / LangGraph useStream → useStreamRuntime (@assistant-ui/react-langchain)
63 ├─ Google ADK → useAdkRuntime (@assistant-ui/react-google-adk)
64 ├─ A2A protocol → useA2ARuntime (@assistant-ui/react-a2a)
65 ├─ AG-UI protocol → useAgUiRuntime (@assistant-ui/react-ag-ui)
66 ├─ Eve agents → useEveAgentRuntime (@assistant-ui/eve)
67 ├─ OpenCode → useOpenCodeRuntime (@assistant-ui/react-opencode)
68 ├─ Claude Managed Agents → useExternalStoreRuntime + useRemoteThreadListRuntime
69 ├─ State already in Redux/Zustand/your store → useExternalStoreRuntime
70 ├─ Custom endpoint speaking Assistant Transport → useAssistantTransportRuntime
71 └─ Any other custom API → useLocalRuntime with a ChatModelAdapter
72```
73
74## Core Packages
75
76| Package | Purpose |
77|---------|---------|
78| `@assistant-ui/react` | Primitives, hooks, runtimes, provider |
79| `@assistant-ui/ai-sdk` | AI SDK v7 integration (`useChatRuntime`, `AssistantChatTransport`, `AISDKToolkit`, `frontendTools`) |
80| `@assistant-ui/core` | Framework-neutral runtime shared by React, React Native, Ink |
81| `@assistant-ui/store` | `AuiConfig`, `AuiProvider`, `useAui` state layer |
82| `@assistant-ui/react-markdown` | Markdown rendering (`MarkdownTextPrimitive`) |
83| `assistant-stream` | Streaming protocol, encoders, resumable streams |
84| `assistant-cloud` | Assistant Cloud client |
85| `assistant-ui` | The CLI (`create`, `init`, `add`, `update`, `upgrade`, `doctor`, `mcp`, `agent`) |
86
87`@assistant-ui/react-ai-sdk` re-exports `@assistant-ui/ai-sdk` for older installs; new code imports from `@assistant-ui/ai-sdk`. Styled components are not a package: `npx assistant-ui@latest add thread` copies them into `components/assistant-ui/elements/`. See [./references/packages.md](./references/packages.md) for the full inventory.
88
89## Quick Start
90
91```tsx
92"use client";
93
94import { AssistantRuntimeProvider } from "@assistant-ui/react";
95import { useChatRuntime } from "@assistant-ui/ai-sdk";
96import { Thread } from "@/components/assistant-ui/elements/thread.aui";
97
98export default function Chat() {
99 const runtime = useChatRuntime();
100 return (
101 <AssistantRuntimeProvider runtime={runtime}>
102 <Thread />
103 </AssistantRuntimeProvider>
104 );
105}
106```
107
108`useChatRuntime()` posts to `/api/chat` through `AssistantChatTransport`, which also forwards frontend tools and system instructions. Pass `new AssistantChatTransport({ api })` to change the endpoint.
109
110## State Access
111
112Scope accessors on `aui` are properties; methods on a scope keep their parentheses. Selectors return one primitive or stable reference each.
113
114```tsx
115import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
116
117const aui = useAui();
118aui.thread.append({ role: "user", content: [{ type: "text", text: "Hi" }] });
119aui.thread.cancelRun();
120aui.thread.composer().send();
121aui.threads.switchToNewThread();
122
123const messages = useAuiState((s) => s.thread.messages);
124const isRunning = useAuiState((s) => s.thread.isRunning);
125
126useAuiEvent("threads.selectionChanged", ({ threadId, previousThreadId }) => {});
127```
128
129## Providing Scopes
130
131Tools, suggestions, interactables, MCP managers, and other scopes are declared with `AuiConfig` and handed to the provider; `useAui()` takes no arguments.
132
133```tsx
134import { AssistantRuntimeProvider, AuiConfig, Suggestions, Tools } from "@assistant-ui/react";
135import { useChatRuntime } from "@assistant-ui/ai-sdk";
136import toolkit from "./toolkit";
137
138const runtime = useChatRuntime();
139const config = AuiConfig({
140 tools: Tools({ toolkit }),
141 suggestions: Suggestions(["What can you do?", "Summarize this page"]),
142});
143
144<AssistantRuntimeProvider runtime={runtime} config={config}>{children}</AssistantRuntimeProvider>;
145```
146
147Nested scopes use `<AuiProvider extends={useAui()} config={config}>`; an isolated root uses `extends={null}`.
148
149## Related Skills
150
151- [setup](../setup/SKILL.md) -- CLI, templates, runtime adapters, platforms
152- [elements](../elements/SKILL.md) -- the styled component catalog and how to install and override it
153- [primitives](../primitives/SKILL.md) -- unstyled building blocks and composer features
154- [runtime](../runtime/SKILL.md) -- runtimes, the aui client, adapters, events
155- [tools](../tools/SKILL.md) -- toolkits, tool UI, approvals, MCP, WebMCP
156- [generative-ui](../generative-ui/SKILL.md) -- the `present` tool and component vocabularies
157- [streaming](../streaming/SKILL.md) -- assistant-stream, transports, resumable streams
158- [cloud](../cloud/SKILL.md) -- Assistant Cloud persistence and auth
159- [thread-list](../thread-list/SKILL.md) -- multi-thread management
160- [copilots](../copilots/SKILL.md) -- grounding the assistant in your app
161- [markdown](../markdown/SKILL.md) -- markdown, code, math, diagrams
162- [react-mcp](../react-mcp/SKILL.md) -- user-managed MCP servers
163- [observability](../observability/SKILL.md) -- tracing and span visualization
164- [react-native](../react-native/SKILL.md) -- Expo and React Native
165- [ink](../ink/SKILL.md) -- terminal chat with Ink
166- [update](../update/SKILL.md) -- upgrades and migrations