Runtime Hooks
Root runtime for managing threads, tool UIs, and assistant state.
The AssistantRuntime is the root runtime of the application.
useAssistantRuntime
import { useAssistantRuntime } from "@assistant-ui/react";
const runtime = useAssistantRuntime();AssistantRuntimethreadsrequired: ThreadListRuntimeThe threads in this assistant.
threadrequired: ThreadRuntimeThe currently selected main thread. Equivalent to `threads.main`.
threadListrequired: ThreadListRuntimeswitchToNewThreadrequired: () => voidSwitch to a new thread.
switchToThreadrequired: (threadId: string) => voidSwitch to a thread.
registerModelContextProviderrequired: (provider: ModelContextProvider) => UnsubscribeRegister a model context provider. Model context providers are configuration such as system message, temperature, etc. that are set in the frontend.
registerModelConfigProviderrequired: (provider: ModelContextProvider) => Unsubscriberesetrequired: unknownTool UI Registry
The tool UI registry is part of the assistant runtime. It allows you to display custom UI for tool calls, enabling generative UI.