with one click
runtime
// Guide for assistant-ui runtime system and state management. Use when working with runtimes, accessing state, or managing thread/message data.
// Guide for assistant-ui runtime system and state management. Use when working with runtimes, accessing state, or managing thread/message data.
Update assistant-ui and AI SDK to latest versions. Detects current versions, identifies breaking changes, and executes migrations.
Setup and configure assistant-ui in a project. Use when installing packages, configuring runtimes, setting up chat UI, or troubleshooting setup issues.
Guide for assistant-ui library - AI chat UI components. Use when asking about architecture, debugging, or understanding the codebase.
Guide for assistant-cloud persistence and authorization. Use when setting up thread persistence, file uploads, or authentication.
Guide for assistant-ui UI primitives - ThreadPrimitive, ComposerPrimitive, MessagePrimitive. Use when customizing chat UI components.
Guide for assistant-stream package and streaming protocols. Use when implementing streaming backends, custom protocols, or debugging stream issues.
| name | runtime |
| description | Guide for assistant-ui runtime system and state management. Use when working with runtimes, accessing state, or managing thread/message data. |
| version | 0.0.1 |
| license | MIT |
Always consult assistant-ui.com/llms.txt for latest API.
AssistantRuntime
āāā ThreadListRuntime (thread management)
ā āāā ThreadListItemRuntime (per-thread item)
ā āāā ...
āāā ThreadRuntime (current thread)
āāā ComposerRuntime (input state)
āāā MessageRuntime[] (per-message)
āāā MessagePartRuntime[] (per-content-part)
import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
function ChatControls() {
const api = useAui();
const messages = useAuiState(s => s.thread.messages);
const isRunning = useAuiState(s => s.thread.isRunning);
useAuiEvent("composer.send", (e) => {
console.log("Sent in thread:", e.threadId);
});
return (
<div>
<button onClick={() => api.thread().append({
role: "user",
content: [{ type: "text", text: "Hello!" }],
})}>
Send
</button>
{isRunning && (
<button onClick={() => api.thread().cancelRun()}>Cancel</button>
)}
</div>
);
}
const api = useAui();
const thread = api.thread();
// Append message
thread.append({ role: "user", content: [{ type: "text", text: "Hello" }] });
// Cancel generation
thread.cancelRun();
// Get current state
const state = thread.getState(); // { messages, isRunning, ... }
const message = api.thread().message(0); // By index
message.edit({ role: "user", content: [{ type: "text", text: "Updated" }] });
message.reload();
useAuiEvent("thread.runStart", () => {});
useAuiEvent("thread.runEnd", () => {});
useAuiEvent("composer.send", ({ threadId }) => {
console.log("Sent in thread:", threadId);
});
useAuiEvent("thread.modelContextUpdate", () => {});
const caps = useAuiState(s => s.thread.capabilities);
// { cancel, edit, reload, copy, speak, attachments }
// Get messages
const messages = useAuiState(s => s.thread.messages);
// Check running state
const isRunning = useAuiState(s => s.thread.isRunning);
// Append message
api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] });
// Cancel generation
api.thread().cancelRun();
// Edit message
api.thread().message(index).edit({ ... });
// Reload message
api.thread().message(index).reload();
"Cannot read property of undefined"
AssistantRuntimeProviderState not updating
useAuiState to prevent unnecessary re-rendersMessages array empty