Integration guide
Generative UI, on your terms.
Agent UI owns the conversation. OpenUI renders structured responses from components you register. Keep backend calls, component schemas and action authorization in your application.
Agent UI provides
ChatShell, streaming state, accessible message layout, approvals, tool cards and an adapter for the official renderer.
Your app provides
OpenUI Lang, a registered component library, agent transport, server-side credentials and authorized action handlers.
1. Define your components
Install @openuidev/react-lang and zod in your application. Register only the components you want a model to generate.
import { defineComponent, createLibrary } from "@openuidev/react-lang";import { z } from "zod/v4";import { Card, CardContent } from "@agent-ui/react"; const StatCard = defineComponent({ name: "StatCard", description: "Display a label and a value.", props: z.object({ label: z.string(), value: z.string() }), component: ({ props }) => ( <Card><CardContent> <p>{props.label}</p><strong>{props.value}</strong> </CardContent></Card> ),}); export const library = createLibrary({ root: "StatCard", components: [StatCard],});2. Render inside a message
Pass the same library and the streamed OpenUI response to the official renderer. Plain text messages can continue using your standard message renderer.
import { Renderer } from "@openuidev/react-lang";import { ChatShell, OpenUIMessage } from "@agent-ui/react";import { library } from "./library"; export function AgentConversation({ chat }) { return ( <ChatShell messages={chat.messages} isStreaming={chat.isStreaming} error={chat.error} onStop={chat.stop} onSend={chat.send} renderMessage={(message, { isStreaming }) => message.role === "assistant" ? ( <OpenUIMessage renderer={Renderer} library={library} response={message.content} isStreaming={isStreaming} onAction={(event) => { // Allowlist actions before handling them. // Never run arbitrary commands from generated text. }} /> ) : message.content } /> );}Security and readiness
Validate generated component props, explicitly allowlist actions and enforce authorization in your backend. The current adapter is implemented, but this repository does not yet ship a fully connected OpenUI generation backend or a live end-to-end sample. Treat the code as an integration example until verified.
Official renderer documentation