logoassistant-ui
API ReferenceRuntime Hooks

AssistantRuntime

The AssistantRuntime is the root runtime of the application.

useAssistantRuntime

import { useAssistantRuntime } from "@assistant-ui/react";
 
const runtime = useAssistantRuntime();

AssistantRuntime

threads:

ThreadListRuntime

The threads in this assistant.

thread:

ThreadRuntime

The currently selected main thread. Equivalent to `threads.main`.

threadList:

ThreadListRuntime

switchToNewThread:

() => void

Switch to a new thread.

switchToThread:

(threadId: string) => void

Switch to a thread.

registerModelContextProvider:

(provider: ModelContextProvider) => Unsubscribe

Register a model context provider. Model context providers are configuration such as system message, temperature, etc. that are set in the frontend.

registerModelConfigProvider:

(provider: ModelContextProvider) => Unsubscribe

reset:

unknown

Tool 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.

useToolUIs

import { useToolUIs } from "@assistant-ui/react";
 
const toolUIs = useToolUIs();
const webSearchToolUI = useToolUIs((m) => m.getToolUI("web_search"));

AssistantToolUIsState

getToolUI:

(toolName: string) => ToolCallContentPartComponent | null

Get the tool UI configured for a given tool name.

setToolUI:

(toolName: string, render: ToolCallContentPartComponent) => Unsubscribe

Registers a tool UI for a given tool name. Returns an unsubscribe function to remove the tool UI.

On this page

Edit on Github