logoassistant-ui
Reference

Runtime API

AssistantRuntimeProvider

The AssistantRuntimeProvider is a React component that wraps your entire app and provides the Runtime to the rest of your app.

import { AssistantRuntimeProvider } from "@assistant-ui/react";
 
const MyApp = () => {
  const chat = useChat();
  const runtime = useVercelUseChatRuntime(chat);
 
  return (
    <AssistantRuntimeProvider runtime={runtime}>
      {/* your app */}
    </AssistantRuntimeProvider>
  );
};

Properties

AssistantRuntimeProviderProps

runtime:

AssistantRuntime

The runtime to provide to the rest of your app.

AssistantRuntime

capabilities:

RuntimeCapabilities

The capabilities of the runtime.

RuntimeCapability

edit:

boolean

Whether the runtime supports editing messages.

reload:

boolean

Whether the runtime supports reloading messages.

cancel:

boolean

Whether the runtime supports cancelling runs.

unstable_copy:

boolean

Whether the runtime supports copying messages.

speak:

boolean

Whether the runtime supports speaking messages.

attachments:

boolean

Whether the runtime supports attachments.

messages:

readonly ThreadMessage[]

The messages in the thread.

isDisabled:

boolean

Whether the thread is disabled.

getBranches:

(messageId: string) => readonly string[]

A function to get the branches for a message.

switchToBranch:

(branchId: string) => void

A function to switch to a branch.

append:

(message: AppendMessage) => void

A function to append a message to the thread.

startRun:

(parentId: string | null) => void

A function to start a run.

cancelRun:

() => void

A function to cancel a run.

addToolResult:

(toolCallId: string, result: any) => void

A function to add a tool result.

subscribe:

(callback: () => void) => Unsubscribe

A function to subscribe to updates.

registerModelConfigProvider:

(provider: ModelConfigProvider) => Unsubscribe

A function to register a model config provider.

On this page

Edit on Github