Loading...
Loading...
Lets the model compose interfaces at runtime from a component vocabulary instead of one hand-written component per tool, and covers every generative UI pattern in the framework. Use for the model-driven present tool: JSONGenerativeUI, defaultGenerativeUILibrary, and present({ display }) from @assistant-ui/react-generative-ui, registered through AuiConfig({ tools: Tools({ toolkit }) }). Also covers the backend-driven MessagePrimitive.GenerativeUI primitive and its component allowlist for a server that already emits generative-ui message parts, the Slack Block Kit and Microsoft Teams Adaptive Card renderers and their action decoders, A2UI surfaces over AG-UI, and the third-party OpenUI integration. Route here when the model should design its own layout rather than fill one you wrote, when an unknown $type or component name throws or silently renders nothing, when a generative UI tree needs to post to Slack or Teams or paint an A2UI surface, or when generative UI, present tool, or component vocabulary comes up. For a widget tied to one tool call you already know about, use tool-ui in ../tools/SKILL.md instead.
npx skill4agent add assistant-ui/skills generative-uipresent@assistant-ui/react-generative-uidefineGenerativeComponents$actioncreateActionRegistry$inputMessagePrimitive.GenerativeUI| Pattern | API | Best for |
|---|---|---|
The | | The model composes dashboards, cards, and layouts from a vocabulary you ship |
| Tool UI | toolkit | A widget tied to one tool call you already know about |
| Generative UI primitive | | A backend that already emits |
| LangGraph data UI | | LangGraph agents emitting UI on the LangGraph stream, see assistant-ui.com/docs/runtimes/langgraph/generative-ui |
| OpenUI | | Already invested in the OpenUI ecosystem and its component kit |
presentpresent"use generative"npm install @assistant-ui/react-generative-ui
npx assistant-ui@latest add generative-uiimport { withAui } from "@assistant-ui/next";
export default withAui({
/* your Next config */
});aui()@assistant-ui/viteplugins: [aui({ ... })]const { withAui } = require("@assistant-ui/metro");metro.config.jsJSONGenerativeUIpresent"use generative";
import { defineToolkit } from "@assistant-ui/react";
import {
JSONGenerativeUI,
defaultGenerativeUILibrary,
} from "@assistant-ui/react-generative-ui";
const generative = new JSONGenerativeUI({
library: defaultGenerativeUILibrary,
});
export default defineToolkit({
present: generative.present({ display: "standalone" }),
});display: "standalone"AuiConfigsendAutomaticallyWhen"use client";
import { AssistantRuntimeProvider, AuiConfig, Tools } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
import toolkit from "./toolkit";
export function MyRuntimeProvider({
children,
}: {
children: React.ReactNode;
}) {
const runtime = useChatRuntime({
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
});
const config = AuiConfig({ tools: Tools({ toolkit }) });
return (
<AssistantRuntimeProvider runtime={runtime} config={config}>
{children}
</AssistantRuntimeProvider>
);
}presentsendAutomaticallyWhenimport { openai } from "@ai-sdk/openai";
import { AISDKToolkit } from "@assistant-ui/ai-sdk";
import { convertToModelMessages, stepCountIs, streamText } from "ai";
import toolkit from "@/app/toolkit";
const aiToolkit = new AISDKToolkit({ toolkit });
export async function POST(req: Request) {
const { messages, tools } = await req.json();
const result = streamText({
model: openai("gpt-5.6-luna"),
messages: await convertToModelMessages(messages),
stopWhen: stepCountIs(10),
tools: await aiToolkit.tools({ frontend: tools }),
});
return result.toUIMessageStreamResponse();
}backendless: truepresentexport default withAui({ ...yourConfig, aui: { backendless: true } });npx assistant-ui@latest add generative-uicomponents/assistant-ui/elements/generative-ui.tsxstyledGenerativeUILibrary"use client""use generative"data-aui$actiongenerative-uiMessagePrimitive.GenerativeUIpresentpresentsendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCallsuseChatRuntimepresentaui: { backendless: true }styledGenerativeUILibrary"use generative""use client""use generative"renderdefineGenerativeComponentslibrarylibrary"use generative"generative-uiThreadMessagePrimitive.GenerativeUIpresent$typeGenerativeUIRenderErrorFallbackhrefsrcdangerouslySetInnerHTMLwarnings$typepresent{ component, props }useChatRuntimegenerative-uitool-callgenerative-uirender_guiparseRenderGuiResult"use generative"generative-uiMessagePrimitiveAuiConfigTools