assistant-ui
π‘ Summary
English summary.
π― Target Audience
π€ AI Roast: βPowerful, but the setup might scare off the impatient.β
Risk: Low. Review: outbound network access (SSRF, data egress). Run with least privilege and audit before enabling in production.
name: assistant-ui description: Guide for assistant-ui library - AI chat UI components. Use when asking about architecture, debugging, or understanding the codebase. version: 0.0.1 license: MIT
assistant-ui
Always consult assistant-ui.com/llms.txt for latest API.
React library for building AI chat interfaces with composable primitives.
References
- ./references/architecture.md -- Core architecture and layered system
- ./references/packages.md -- Package overview and selection guide
When to Use
| Use Case | Best For | |----------|----------| | Chat UI from scratch | Full control over UX | | Existing AI backend | Connects to any streaming backend | | Custom message types | Tools, images, files, custom parts | | Multi-thread apps | Built-in thread list management | | Production apps | Cloud persistence, auth, analytics |
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β UI Components (Primitives) β
β ThreadPrimitive, MessagePrimitive, ComposerPrimitive β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ
β Context Hooks β
β useAssistantApi, useAssistantState, useAssistantEvent β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ
β Runtime Layer β
β AssistantRuntime β ThreadRuntime β MessageRuntime β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ
β Adapters/Backend β
β AI SDK Β· LangGraph Β· Custom Β· Cloud Persistence β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Pick a Runtime
Using AI SDK?
ββ Yes β useChatRuntime (recommended)
ββ No
ββ External state (Redux/Zustand)? β useExternalStoreRuntime
ββ LangGraph agent? β useLangGraphRuntime
ββ AG-UI protocol? β useAgUiRuntime
ββ A2A protocol? β useA2ARuntime
ββ Custom API β useLocalRuntime
Core Packages
| Package | Purpose |
|---------|---------|
| @assistant-ui/react | UI primitives & hooks |
| @assistant-ui/react-ai-sdk | Vercel AI SDK v6 adapter |
| @assistant-ui/react-langgraph | LangGraph adapter |
| @assistant-ui/react-markdown | Markdown rendering |
| @assistant-ui/styles | Pre-built CSS |
| assistant-stream | Streaming protocol |
| assistant-cloud | Cloud persistence |
Quick Start
import { AssistantRuntimeProvider, Thread } from "@assistant-ui/react"; import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk"; function App() { const runtime = useChatRuntime({ transport: new AssistantChatTransport({ api: "/api/chat" }), }); return ( <AssistantRuntimeProvider runtime={runtime}> <Thread /> </AssistantRuntimeProvider> ); }
State Access
import { useAssistantApi, useAssistantState } from "@assistant-ui/react"; const api = useAssistantApi(); api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] }); api.thread().cancelRun(); const messages = useAssistantState(s => s.thread.messages); const isRunning = useAssistantState(s => s.thread.isRunning);
Related Skills
/setup- Installation and configuration/primitives- UI component customization/runtime- State management deep dive/tools- Tool registration and UI/streaming- Streaming protocols/cloud- Persistence and auth/thread-list- Multi-thread management/update- Version updates and migrations
Pros
- p1
- p2
Cons
- c1
- c2
Related Skills
claude-domain-skills
BβPowerful, but the setup might scare off the impatient.β
my-skills
BβPowerful, but the setup might scare off the impatient.β
terraform-ibm-modules-skills
BβPowerful, but the setup might scare off the impatient.β
Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.
Copyright belongs to the original author assistant-ui.
