Transport
Frame bridge APIs and serialized message types for embedding assistant-ui runtimes in external contexts.
API Reference
AssistantFrameHost
AssistantFrameHostconstructor?: (iframeWindow: Window, targetOrigin: string = "*") => AssistantFrameHostgetModelContext?: () => ModelContextsubscribe?: (callback: () => void) => Unsubscribedispose?: () => voidAssistantFrameProvider
AssistantFrameProviderstatic addModelContextProvider?: (provider: ModelContextProvider, targetOrigin?: string) => Unsubscribestatic dispose?: () => voidFRAME_MESSAGE_CHANNEL
const FRAME_MESSAGE_CHANNEL: "assistant-ui-frame";FrameMessage
FrameMessagetype: "model-context-request"SerializedModelContext
SerializedModelContextsystem?: stringtools?: Record<string, SerializedTool>SerializedTool
SerializedTooldescription?: stringparameters: anydisabled?: booleantype?: stringuseAssistantFrameHost
React hook that manages the lifecycle of an AssistantFrameHost and its binding to the current AssistantRuntime.
Usage example:
function MyComponent() {
const iframeRef = useRef<HTMLIFrameElement>(null);
useAssistantFrameHost({
iframeRef,
targetOrigin: "https://trusted-domain.com", // optional
});
return <iframe ref={iframeRef} src="..." />;
}useAssistantFrameHostoptions: UseAssistantFrameHostOptionsiframeRef: Readonly<RefObject<HTMLIFrameElement | null | undefined>>targetOrigin?: stringregister: (frameHost: AssistantFrameHost) => Unsubscribe