The Open Standard for Generative UI
docs: rework Introduction and Getting Started (#1278)
abhithesys077b7bd10759
diff --git a/docs/app/chat/_components/chat-page-header.tsx b/docs/app/chat/_components/chat-page-header.tsxindex f83953c11..9be389862 100644--- a/docs/app/chat/_components/chat-page-header.tsx+++ b/docs/app/chat/_components/chat-page-header.tsx@@ -6,9 +6,25 @@ import { ToggleGroup } from "@openuidev/react-ui/ToggleGroup";import { ToggleItem } from "@openuidev/react-ui/ToggleItem";import { ArrowLeft, Monitor, Smartphone, Tablet } from "lucide-react";import Link from "next/link";+import { useRouter } from "next/navigation";+import type { MouseEvent } from "react";import styles from "../chat-page.module.css";import { isViewportPreset, type ViewportPreset } from "./viewport-presets";+// Only go back when the previous entry is on this site, so the button never+// sends someone off to wherever they were before landing on the demo.+function canGoBackInApp(): boolean {+ const navigation = (window as { navigation?: { canGoBack?: boolean } }).navigation;+ if (typeof navigation?.canGoBack === "boolean") return navigation.canGoBack;++ if (window.history.length <= 1 || !document.referrer) return false;+ try {+ return new URL(document.referrer).origin === window.location.origin;+ } catch {+ return false;+ }+}+const VIEWPORT_OPTIONS = [{ id: "mobile", label: "Mobile", icon: Smartphone },{ id: "tablet", label: "Tablet", icon: Tablet },@@ -26,10 +42,27 @@ export function ChatPageHeader({availableViewports,onViewportChange,}: ChatPageHeaderProps) {+ const router = useRouter();++ const handleBackClick = (event: MouseEvent<HTMLAnchorElement>) => {+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) {+ return;+ }+ if (!canGoBackInApp()) return;+ event.preventDefault();+ router.back();+ };+return (<header className={styles.header} aria-label="OpenUI chat controls"><div className={styles.headerRow}>- <Link className={styles.backLink} href="/" prefetch={false} aria-label="Back to docs">+ <Link+ className={styles.backLink}+ href="/"+ prefetch={false}+ aria-label="Back"+ onClick={handleBackClick}+ ><ArrowLeft aria-hidden="true" size={15} strokeWidth={2} /></Link>diff --git a/docs/components/docs-page.tsx b/docs/components/docs-page.tsxindex b1bd2eba5..2342bd6a3 100644--- a/docs/components/docs-page.tsx+++ b/docs/components/docs-page.tsx@@ -13,7 +13,7 @@ export function DocsPageView({ page }: { page: DocsSourcePage }) {const MDX = page.data.body;return (- <DocsPage toc={page.data.toc} full={page.data.full}>+ <DocsPage toc={page.data.toc} full={page.data.full} footer={{ enabled: !page.data.hideFooter }}>{!page.data.customHeader && (<><DocsTitle>{page.data.title}</DocsTitle>diff --git a/docs/components/openui-flow-diagram.tsx b/docs/components/openui-flow-diagram.tsxnew file mode 100644index 000000000..79ecc56bd--- /dev/null+++ b/docs/components/openui-flow-diagram.tsx@@ -0,0 +1,328 @@+import {+ AppWindow,+ Blocks,+ Bot,+ Cloud,+ Server,+ Sparkles,+ Wrench,+ type LucideIcon,+} from "lucide-react";++type Box = {+ x: number;+ y: number;+ width: number;+ height: number;+ icon: LucideIcon;+ title: string;+ lines: string[];+ footer?: string;+ highlight?: boolean;+ compact?: boolean;+ // Top of the icon, when the content should not start at the top of the box.+ contentY?: number;+};++const boxes: Box[] = [+ {+ x: 10,+ y: 40,+ width: 200,+ height: 184,+ icon: AppWindow,+ title: "Your frontend",+ lines: ["Renders the stream", "with your components"],+ footer: "e.g. Agent Interface",+ },+ {+ x: 10,+ y: 330,+ width: 200,+ height: 150,+ icon: Blocks,+ title: "Component library",+ lines: ["What the model uses"],+ compact: true,+ },+ {+ x: 290,+ y: 20,+ width: 150,+ height: 520,+ icon: Server,+ title: "Your backend",+ lines: ["Runs your agent", "and tools"],+ footer: "Your code",+ contentY: 190,+ },+ {+ x: 530,+ y: 75,+ width: 180,+ height: 175,+ icon: Sparkles,+ title: "OpenUI Gateway",+ lines: ["Any model, one API", "Fixes the stream"],+ highlight: true,+ },+ {+ x: 820,+ y: 75,+ width: 180,+ height: 175,+ icon: Bot,+ title: "Any model",+ lines: ["OpenAI, Anthropic,", "and more"],+ },+ {+ x: 530,+ y: 410,+ width: 180,+ height: 110,+ icon: Wrench,+ title: "Autofix",+ lines: ["Fixes the output"],+ highlight: true,+ compact: true,+ },+ {+ x: 820,+ y: 345,+ width: 180,+ height: 175,+ icon: Cloud,+ title: "Your provider",+ lines: ["Called directly", "by your backend"],+ },+];++const lanes = [+ { y: 20, height: 250, title: "Through OpenUI Gateway", tag: "Recommended" },+ { y: 290, height: 250, title: "Call models directly" },+];++const label = "fill-fd-foreground font-mono text-[13px] font-bold uppercase tracking-[0.1em]";++function BoxNode({ box }: { box: Box }) {+ const center = box.x + box.width / 2;+ const Icon = box.icon;+ const iconY = box.contentY ?? box.y + (box.compact ? 16 : 22);+ const titleY = iconY + (box.compact ? 54 : 62);+ return (+ <g>+ <rect+ x={box.x}+ y={box.y}+ width={box.width}+ height={box.height}+ rx={12}+ strokeWidth={1.75}+ className={+ box.highlight+ ? "fill-[#eef1fb] stroke-fd-foreground dark:fill-[#1c2233]"+ : "fill-fd-background stroke-fd-foreground"+ }+ />+ <Icon+ x={center - 15}+ y={iconY}+ width={30}+ height={30}+ strokeWidth={1.6}+ className="text-fd-foreground"+ aria-hidden="true"+ />+ <text+ x={center}+ y={titleY}+ textAnchor="middle"+ className="fill-fd-foreground font-mono text-[16px] font-bold uppercase tracking-[0.05em]"+ >+ {box.title}+ </text>+ {box.lines.map((line, index) => (+ <text+ key={line}+ x={center}+ y={titleY + (box.compact ? 26 : 30) + index * 24}+ textAnchor="middle"+ className="fill-fd-muted-foreground font-sans text-[15.5px]"+ >+ {line}+ </text>+ ))}+ {box.footer && (+ <text+ x={center}+ y={box.y + box.height - 16}+ textAnchor="middle"+ className="fill-fd-muted-foreground font-mono text-[12px] font-semibold uppercase tracking-[0.12em]"+ >+ {box.footer}+ </text>+ )}+ </g>+ );+}++function Arrow({ x1, y1, x2, y2 }: { x1: number; y1: number; x2: number; y2: number }) {+ return (+ <line+ x1={x1}+ y1={y1}+ x2={x2}+ y2={y2}+ stroke="currentColor"+ strokeWidth={1.6}+ markerEnd="url(#openui-flow-arrow)"+ />+ );+}++// A request and its reply between two boxes, read left to right.+function Exchange({+ from,+ to,+ y,+ gap = 45,+ request,+ reply,+ labelX,+}: {+ from: number;+ to: number;+ y: number;+ gap?: number;+ request: string;+ reply: string;+ labelX?: number;+}) {+ const center = labelX ?? (from + to) / 2;+ return (+ <g>+ <Arrow x1={from + 4} y1={y} x2={to - 6} y2={y} />+ <text x={center} y={y - 12} textAnchor="middle" className={label}>+ {request}+ </text>+ <Arrow x1={to - 4} y1={y + gap} x2={from + 6} y2={y + gap} />+ <text x={center} y={y + gap + 22} textAnchor="middle" className={label}>+ {reply}+ </text>+ </g>+ );+}++export function OpenUIFlowDiagram() {+ return (+ <figure className="not-prose my-8 overflow-x-auto">+ <svg+ viewBox="0 0 1020 560"+ role="img"+ aria-labelledby="openui-flow-title openui-flow-description"+ className="h-auto w-full min-w-[640px] text-fd-foreground"+ >+ <title id="openui-flow-title">How OpenUI works</title>+ <desc id="openui-flow-description">+ Your component library gives your frontend its components and your backend its system+ prompt. Your frontend sends a message to your backend, which calls a model in one of two+ ways. The recommended way is through OpenUI Gateway, which calls any model and fixes the+ OpenUI Lang stream as it arrives. Alternatively, your backend calls your model provider+ directly and sends invalid output to Autofix to be fixed. Your backend streams the+ generated UI back to your frontend.+ </desc>+ <defs>+ <marker+ id="openui-flow-arrow"+ viewBox="0 0 10 10"+ refX="9"+ refY="5"+ markerWidth="11"+ markerHeight="11"+ markerUnits="userSpaceOnUse"+ orient="auto-start-reverse"+ >+ <path+ d="M1 1 L9 5 L1 9"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.6"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </marker>+ </defs>++ {lanes.map((lane) => (+ <g key={lane.title}>+ <rect+ x={500}+ y={lane.y}+ width={515}+ height={lane.height}+ rx={16}+ strokeWidth={1.25}+ strokeDasharray="6 6"+ className="fill-fd-muted/40 stroke-fd-muted-foreground/60"+ />+ <text x={520} y={lane.y + 32} className={label}>+ {lane.title}+ </text>+ {lane.tag && (+ <g>+ <rect+ x={740}+ y={lane.y + 14}+ width={132}+ height={26}+ rx={13}+ className="fill-fd-foreground"+ />+ <text+ x={806}+ y={lane.y + 32}+ textAnchor="middle"+ className="fill-fd-background font-mono text-[11.5px] font-bold uppercase tracking-[0.12em]"+ >+ {lane.tag}+ </text>+ </g>+ )}+ </g>+ ))}++ <Exchange from={210} to={290} y={108} gap={50} request="Message" reply="Stream" />++ {/* The component library feeds both the renderer and the system prompt. */}+ <Arrow x1={110} y1={326} x2={110} y2={230} />+ <text x={122} y={283} className={label}>+ Components+ </text>+ <Arrow x1={214} y1={405} x2={284} y2={405} />+ <text x={250} y={393} textAnchor="middle" className={label}>+ Prompt+ </text>++ {/* Through Gateway. */}+ <Exchange from={440} to={530} y={140} request="Request" reply="Stream" />+ <Exchange from={710} to={820} y={140} request="Prompt" reply="OpenUI Lang" />++ {/* Directly: your backend calls your provider, then sends invalid output to Autofix. */}+ <Exchange+ from={440}+ to={820}+ y={365}+ gap={30}+ request="Prompt"+ reply="OpenUI Lang"+ labelX={765}+ />+ <Exchange from={440} to={530} y={455} gap={35} request="Output" reply="Fixed" />++ {boxes.map((box) => (+ <BoxNode key={box.title} box={box} />+ ))}+ </svg>+ </figure>+ );+}diff --git a/docs/content/docs/architecture.mdx b/docs/content/docs/architecture.mdxdeleted file mode 100644index 81fb2a97b..000000000--- a/docs/content/docs/architecture.mdx+++ /dev/null@@ -1,159 +0,0 @@-----title: How OpenUI works------Most AI applications are limited to returning text as Markdown or rendering pre-built UI responses. Markdown isn't interactive, and pre-built responses are rigid—they don't adapt to the context of the conversation.--Generative UI fundamentally changes this relationship. Instead of merely providing content, the AI composes the interface itself. It dynamically selects, configures, and combines components from a predefined library to create a purpose-built interface tailored to the user's immediate request, whether that's an interactive chart, a complex form, or a multi-tab dashboard.--[Try demo](/chat)--## How it works--<figure className="not-prose my-8">- <img- src="/images/openui-architecture.svg"- alt="A user request travels from an application through OpenUI Gateway to a model provider. The corrected OpenUI Lang stream returns to a renderer, with Reliability Monitoring tracking generation failures."- className="m-0 block h-auto w-full overflow-hidden rounded-2xl"- />- <figcaption className="mt-2 text-center text-xs leading-5 text-fd-muted-foreground">- Generation through Gateway- </figcaption>-</figure>--Your application provides a library of components and the relevant context. The model generates OpenUI Lang, and the renderer displays it using your components. Gateway can correct output during streaming, or Autofix can repair completed output from your existing inference setup. Reliability Monitoring helps you find failures and improve reliability.--## OpenUI Lang--OpenUI Lang is a compact, line-oriented language for describing generated interfaces. You define the components the model can use in a component library:--```tsx-import { createLibrary } from "@openuidev/react-lang";-import { Chart, Metric, Stack } from "./components";--export const library = createLibrary({- root: "Stack",- components: [Stack, Metric, Chart],-});-```--OpenUI turns the component library into a system prompt that describes the available components and their properties. The model uses these instructions to generate OpenUI Lang, which streams to your application and renders with your components.--Learn more in the [OpenUI Lang documentation](/docs/openui-lang).--## Gateway--OpenUI Gateway is a reliability layer between your application and AI model providers. It routes requests across providers, validates generated interfaces, and corrects invalid model output before it reaches your application.--<div- className="not-prose my-6 rounded-2xl border border-fd-border bg-fd-muted/20 p-4 sm:p-6"- role="img"- aria-label="A request travels from an application through OpenUI Gateway to an LLM. The LLM streams generated UI through OpenUI Gateway, which validates the stream continuously, fixes errors as they are detected, and forwards the validated stream to the application."->- <div className="grid items-stretch gap-3 md:grid-cols-[minmax(0,1fr)_7rem_minmax(0,1.15fr)_7rem_minmax(0,1fr)]">- <div className="flex min-h-40 flex-col rounded-xl border border-fd-border bg-fd-background p-4">- <div className="text-sm font-semibold text-fd-foreground">Your application</div>- <div className="mt-4 flex flex-1 flex-col gap-2 rounded-lg border border-fd-border bg-fd-muted/40 p-3">- <div className="h-2 w-2/3 rounded-full bg-fd-muted-foreground/25" />- <div className="h-2 w-1/2 rounded-full bg-fd-muted-foreground/20" />- <div className="mt-2 flex-1 rounded-md border border-[color:color-mix(in_srgb,var(--openui-text-success-primary)_25%,transparent)] bg-[var(--openui-success-background)] p-2">- <div className="text-xs font-medium text-[var(--openui-text-success-primary)]">- Generated interface- </div>- <div className="mt-2 h-2 w-full rounded-full bg-fd-muted-foreground/20" />- <div className="mt-2 h-2 w-3/4 rounded-full bg-fd-muted-foreground/20" />- </div>- </div>- </div>-- <div className="flex items-center justify-around py-1 text-xs font-medium text-fd-muted-foreground md:hidden">- <div className="flex flex-col items-center gap-1">- <span>Request</span>- <span className="text-lg" aria-hidden="true">↓</span>- </div>- <div className="flex flex-col items-center gap-1 text-[var(--openui-text-success-primary)]">- <span aria-hidden="true">↑</span>- <span>Validated UI</span>- </div>- </div>- <div className="hidden flex-col items-center justify-center gap-10 text-xs font-medium md:flex">- <div className="whitespace-nowrap text-fd-muted-foreground">Request →</div>- <div className="whitespace-nowrap text-[var(--openui-text-success-primary)]">- ← Validated UI- </div>- </div>-- <div className="flex min-h-40 flex-col rounded-xl border border-[var(--openui-text-purple-primary)] bg-[var(--openui-purple-background)] p-4 shadow-sm">- <div className="text-sm font-semibold text-fd-foreground">OpenUI Gateway</div>- <div className="text-xs font-medium text-[var(--openui-text-purple-primary)]">- Reliability middleware- </div>- <div className="mt-4 flex flex-1 flex-col justify-center gap-2">- <div className="rounded-lg border border-[color:color-mix(in_srgb,var(--openui-text-purple-primary)_30%,transparent)] bg-fd-background/70 px-3 py-2 text-xs font-medium text-fd-foreground">- Validate generated UI- </div>- <div className="rounded-lg border border-[color:color-mix(in_srgb,var(--openui-text-purple-primary)_30%,transparent)] bg-fd-background/70 px-3 py-2 text-xs font-medium text-fd-foreground">- Fix errors automatically- </div>- </div>- </div>-- <div className="flex items-center justify-around py-1 text-xs font-medium text-fd-muted-foreground md:hidden">- <div className="flex flex-col items-center gap-1">- <span>Model request</span>- <span className="text-lg" aria-hidden="true">↓</span>- </div>- <div className="flex flex-col items-center gap-1 text-[var(--openui-text-alert-primary)]">- <span aria-hidden="true">↑</span>- <span>Generated UI</span>- </div>- </div>- <div className="hidden flex-col items-center justify-center gap-10 text-xs font-medium text-fd-muted-foreground md:flex">- <div className="whitespace-nowrap">Model request →</div>- <div className="whitespace-nowrap text-[var(--openui-text-alert-primary)]">- ← Generated UI- </div>- </div>-- <div className="flex min-h-40 flex-col rounded-xl border border-fd-border bg-fd-background p-4">- <div className="text-sm font-semibold text-fd-foreground">LLM</div>- <div className="text-xs text-fd-muted-foreground">OpenAI, Anthropic, and others</div>- <div className="mt-4 flex flex-1 items-center justify-center rounded-lg border border-[color:color-mix(in_srgb,var(--openui-text-alert-primary)_25%,transparent)] bg-[var(--openui-alert-background)] px-3 text-center text-xs font-medium text-[var(--openui-text-alert-primary)]">- Generate interface- </div>- </div>- </div>-</div>--### Integration options--OpenUI Gateway provides two OpenAI-compatible APIs:--- **[Chat Completions](/docs/gateway/api/chat-completions):** A drop-in endpoint for applications that use the OpenAI Chat Completions API.-- **[Responses API](/docs/gateway/api/responses):** Build stateful model interactions with persistence and hosted tools.--Learn more in the [OpenUI Gateway documentation](/docs/gateway).--## Autofix--Reliability for your own inference. Correct model output that would break your interface, without changing your model provider or inference setup.--Learn more in the [Autofix docs](/docs/autofix).--## Reliability Monitoring--Generative UI depends on model providers and model-generated output. Providers can fail, and models can generate invalid or incomplete interfaces.--Reliability Monitoring helps you find these failures in production, trace affected generations, and identify recurring patterns. These insights help you improve your system prompt, component library, and model selection.--Monitoring is automatically enabled for Gateway generations and Autofix requests. If you use neither, connect the [Observability SDK](/docs/reliability/installation) to track parsing and rendering errors in your application.--<img- src="/images/openui-lang/reliability-dashboard.png"- alt="Reliability Monitoring dashboard showing generation errors and affected interfaces"- className="w-full rounded-lg border"-/>--Reliability Monitoring identifies errors. Use Gateway or Autofix to correct invalid generated output.--Learn more in the [Reliability Monitoring docs](/docs/reliability).diff --git a/docs/content/docs/autofix.mdx b/docs/content/docs/autofix.mdxindex 6de2cb8df..ad28375fd 100644--- a/docs/content/docs/autofix.mdx+++ b/docs/content/docs/autofix.mdx@@ -66,7 +66,7 @@ const model = new OpenAI();export async function POST(request: Request) {const { messages } = await request.json();const source = await model.chat.completions.create(- { model: "openai/gpt-5.5", messages, stream: true },+ { model: "gpt-5.5", messages, stream: true },{ signal: request.signal },);diff --git a/docs/content/docs/getting-started.mdx b/docs/content/docs/getting-started.mdxindex 084e63b75..06e010e9c 100644--- a/docs/content/docs/getting-started.mdx+++ b/docs/content/docs/getting-started.mdx@@ -3,97 +3,132 @@ title: Getting Starteddescription: Create a new OpenUI application or add OpenUI to an existing agent.----Start a new agent application with the OpenUI CLI, or add OpenUI to an application you already have.+import { OpenUIFlowDiagram } from "@/components/openui-flow-diagram";-## Start a new application+## Create a new app-You need Node.js 20 or later. Run the interactive setup to choose your model connection and agent framework:+You need Node.js 20 or later. Run:```bashnpx @openuidev/cli@latest create```-The CLI creates the project, installs its dependencies, and can start the development server for you.+The interactive setup asks how to connect to a model and which agent framework to use, then creates the project, installs its dependencies, and can start the development server for you. See the [CLI reference](/docs/api-reference/cli) for templates, framework options, and deploying a preview.-### Choose a model connection+## End-to-end integration-Use OpenUI Gateway for model access, output correction, and provider fallbacks:+Add OpenUI to an existing application: define the components the model can use, call a model with a system prompt generated from them, and render the response.-```bash-npx @openuidev/cli@latest create --name my-agent --template openui-cloud+<OpenUIFlowDiagram />++### 1. Create a component library++Create a library containing the components the model can use:++```tsx title="src/lib/openui.tsx"+import { createLibrary } from "@openuidev/react-lang";+import { Chart, Metric, Stack } from "./components";++export const library = createLibrary({+ root: "Stack",+ components: [Stack, Metric, Chart],+});```-Or connect the generated application directly to your own model provider:+Learn more about defining components in the [OpenUI Lang documentation](/docs/openui-lang/defining-components).++### 2. Export the library specification++Use the OpenUI CLI to serialize the component library for your server:```bash-npx @openuidev/cli@latest create --name my-agent --template openui-self-hosted+npx @openuidev/cli@latest generate src/lib/openui.tsx --spec --out src/lib/openui.spec.json```-### Choose an agent framework+The generated specification describes the available components and their properties. Regenerate it whenever the component library changes.-Add `--backend-framework` to scaffold an integration for a specific agent framework. These options can be combined with either model setup.+### 3. Call a model-```bash tab="Default" tab-group="agent-framework"-npx @openuidev/cli@latest create \- --name my-agent \- --template openui-cloud \- --backend-framework default-```+Generate the system prompt from the library specification and send it with the user's message.-```bash tab="Vercel AI SDK" tab-group="agent-framework"-npx @openuidev/cli@latest create \- --name my-agent \- --template openui-cloud \- --backend-framework vercel-ai-sdk-```+```ts title="server.ts" tab="OpenUI Gateway (recommended)" tab-group="call-model"+import OpenAI from "openai";+import { generateSystemPrompt } from "@openuidev/lang-core";+import library from "./lib/openui.spec.json";-```bash tab="LangGraph" tab-group="agent-framework"-npx @openuidev/cli@latest create \- --name my-agent \- --template openui-cloud \- --backend-framework langgraph-```+const gateway = new OpenAI({+ apiKey: process.env.THESYS_API_KEY,+ baseURL: "https://api.thesys.dev/v1/embed",+});-```bash tab="Vercel Eve" tab-group="agent-framework"-npx @openuidev/cli@latest create \- --name my-agent \- --template openui-cloud \- --backend-framework vercel-eve+const completion = await gateway.chat.completions.create({+ model: "openai/gpt-5",+ messages: [+ { role: "system", content: generateSystemPrompt({ cloud: true, library }) },+ { role: "user", content: "Compare quarterly revenue by region." },+ ],+ stream: true,+});```-The generated application includes [Agent Interface](/docs/agent/getting-started/introduction) and an OpenUI Lang component library. Follow the [Agent Interface Quickstart](/docs/agent/getting-started/quickstart) to understand the generated project.+```ts title="server.ts" tab="OpenAI" tab-group="call-model"+import OpenAI from "openai";+import { generateSystemPrompt } from "@openuidev/lang-core";+import { createAutofix } from "@openuidev/server/openai";+import library from "./lib/openui.spec.json";++const model = new OpenAI();+const autofix = createAutofix({ apiKey: process.env.THESYS_API_KEY!, library });++const messages = [{ role: "user" as const, content: "Compare quarterly revenue by region." }];-### Share a preview+const source = await model.chat.completions.create({+ model: "gpt-5",+ messages: [{ role: "system", content: generateSystemPrompt({ library }) }, ...messages],+ stream: true,+});++// Autofix adds the library itself, so pass only the conversation.+// Return this from your API route as a server-sent events response.+const response = autofix.completions.stream({ stream: source, messages }).toResponse();+```-From the project directory, deploy a Vercel preview without installing the Vercel CLI:+Both examples use a `THESYS_API_KEY`. Run the command below to sign in with Thesys, create a key, and write it to your `.env` file. Keep the key on the server and never expose it to browser code.```bash-npx @openuidev/cli@latest deploy+npx @openuidev/cli@latest generate-api-key```-See the [CLI reference](/docs/api-reference/cli#deploy) for `--prod`, `--yes`, and `--skip-env`.+The OpenAI example uses [Autofix](/docs/autofix) to repair invalid OpenUI Lang against your library before it reaches your application. Gateway does this for you as the response streams.-## Add OpenUI to an existing application+You can also use Anthropic, Gemini, or any other LLM provider. Send the generated system prompt with your provider's SDK.-<Cards>- <Card title="assistant-ui or CopilotKit" href="/docs/build-agents">- Keep your existing conversation experience and add OpenUI Lang rendering.- </Card>- <Card title="Custom chat UI" href="/docs/build-agents/custom-chat-ui">- Render generated interfaces inside your existing message list.- </Card>- <Card title="Agent backend" href="/docs/gateway/generate-openui-lang">- Route model requests through OpenUI Gateway and generate validated OpenUI Lang.- </Card>-</Cards>+### 4. Render the UI-## Build only with OpenUI Lang+Pass the accumulated OpenUI Lang text to `<Renderer />`. Set `isStreaming` until the server stream closes.++```tsx title="src/components/generated-interface.tsx"+"use client";++import { Renderer } from "@openuidev/react-lang";+import { library } from "@/lib/openui";++export function GeneratedInterface({ response, isStreaming }) {+ return (+ <Renderer+ response={response}+ library={library}+ isStreaming={isStreaming}+ onAction={(action) => console.log(action)}+ />+ );+}+```-Use OpenUI Lang without adopting a complete agent interface or hosted model service:+The renderer displays the interface progressively as the response arrives.-1. [Define the components](/docs/openui-lang/defining-components) the model can use.-2. [Generate the system prompt](/docs/openui-lang/system-prompts) from the component library.-3. Send those instructions to your chosen model or agent framework.-4. [Render the streamed response](/docs/openui-lang/renderer) with your application components.+## Next steps-Learn more in the [OpenUI Lang documentation](/docs/openui-lang).+- **Add a chat interface:** use [Agent Interface](/docs/agent/getting-started/introduction) for a complete chat UI, add OpenUI to [assistant-ui or CopilotKit](/docs/build-agents), or render generated UI in a [custom chat UI](/docs/build-agents/custom-chat-ui).+- **Go deeper on OpenUI Lang:** learn about [defining components](/docs/openui-lang/defining-components), [system prompts](/docs/openui-lang/system-prompts), and the [renderer](/docs/openui-lang/renderer).+- **Run it in production:** read [OpenUI in production](/docs/production), set up [Reliability Monitoring](/docs/reliability), and [deploy your app](/docs/deploy).diff --git a/docs/content/docs/index.mdx b/docs/content/docs/index.mdxindex f67ed336b..536cc26c7 100644--- a/docs/content/docs/index.mdx+++ b/docs/content/docs/index.mdx@@ -1,32 +1,58 @@---title: Introduction+hideFooter: true----import { TryItOut } from "./openui-lang/components/try-it-out";+import { OpenUIFlowDiagram } from "@/components/openui-flow-diagram";-OpenUI is a Generative UI toolkit for creating agents that respond with live, interactive interfaces instead of only text. It provides the building blocks for interfaces that adapt to each request while remaining consistent with your product and design system.+OpenUI is the open standard for Generative UI. At its core is **OpenUI Lang**, a compact language that lets models respond with live, interactive interfaces built from your own components, instead of only text. OpenUI Lang works with any model, agent framework, or chat UI.-<TryItOut />+<div className="not-prose my-6 overflow-hidden rounded-xl border border-fd-border">+ <video+ src="/videos/openui-introduction.mp4"+ poster="/videos/openui-introduction-poster.jpg"+ aria-label="An OpenUI agent answering a question with a generated interface of stat cards and tables"+ autoPlay+ muted+ loop+ playsInline+ preload="metadata"+ className="block h-auto w-full"+ />+</div>-## OpenUI stack+[Try the live demo →](/chat)-OpenUI provides the building blocks for creating generated interfaces and running them reliably in production.+Most AI applications are limited to returning text as Markdown or rendering pre-built UI responses. Markdown isn't interactive, and pre-built responses are rigid. They don't adapt to the context of the conversation.-<Cards>- <Card title="OpenUI Lang" href="/docs/openui-lang">- Generate UI from your components in up to 67% fewer tokens than JSON.- </Card>- <Card title="Gateway" href="/docs/gateway">- OpenRouter for Generative UI, with provider fallbacks and Autofix built in.- </Card>- <Card title="Autofix" href="/docs/autofix">- Fix model output that would break your UI, using your existing provider.- </Card>- <Card title="Reliability Monitoring" href="/docs/reliability">- Track failed generations, inspect affected interfaces, and spot recurring errors.- </Card>-</Cards>+With Generative UI, the model composes the interface itself. It selects, configures, and combines components from your component library to build an interface for each request, whether that's an interactive chart, a form, or a multi-tab dashboard.-Learn about correction and monitoring options in [OpenUI in production](/docs/production).+## How it works++You define the components. The model decides how to combine them for each request, and your application renders the result.++<OpenUIFlowDiagram />++1. **Define your component library:** the components the model can use to generate UI.+2. **Generate the system prompt:** OpenUI turns the library into instructions for the model.+3. **Call a model:** through [OpenUI Gateway](/docs/gateway) (recommended), which validates and fixes the generation as it streams, or directly with your own provider, using [Autofix](/docs/autofix) to repair invalid output.+4. **Render the stream:** the `Renderer` draws each component as its line arrives.++See it end to end in [Getting Started](/docs/getting-started).++## What's in OpenUI-Ready to build? [Get started with OpenUI](/docs/getting-started).+OpenUI gives you the tools to build Generative UI into your application and run it reliably in production.++To build Generative UI:++- **[OpenUI Lang](/docs/openui-lang):** Describes interfaces with your own components. Models generate it in less than half the tokens of JSON-based formats, and the renderer displays it progressively as it streams.+- **[Agent Interface](/docs/agent/getting-started/introduction):** A React SDK for a complete chat interface, with threads, streaming messages, tool activity, and generated components. Connect it to your existing agent backend, or add the renderer to assistant-ui, CopilotKit, or your own chat UI instead.++To run it in production:++- **[Gateway](/docs/gateway):** OpenRouter for Generative UI. One API for models across providers, with automatic failover when a provider is unavailable and Autofix built in to correct invalid OpenUI Lang as it streams.+- **[Autofix](/docs/autofix):** Repairs invalid OpenUI Lang after generation with one API call. Keep your existing model provider, inference setup, and agent framework.+- **[Reliability Monitoring](/docs/reliability):** Shows how often generated interfaces fail, which errors recur, and the generation behind each failure. It's enabled automatically with Gateway and Autofix, or through the Observability SDK with your own inference.++Learn about correction and monitoring options in [OpenUI in production](/docs/production).diff --git a/docs/content/docs/meta.json b/docs/content/docs/meta.jsonindex 6fcc05369..c691f2a61 100644--- a/docs/content/docs/meta.json+++ b/docs/content/docs/meta.json@@ -3,7 +3,6 @@"pages": ["index","getting-started",- "architecture","openui-lang","build-agents","agent",diff --git a/docs/lib/docs-navigation.test.ts b/docs/lib/docs-navigation.test.tsindex 04c3f56e7..71eb930ac 100644--- a/docs/lib/docs-navigation.test.ts+++ b/docs/lib/docs-navigation.test.ts@@ -30,12 +30,6 @@ describe("global docs navigation", () => {url: "/docs/getting-started",children: undefined,},- {- type: "page",- name: "How OpenUI works",- url: "/docs/architecture",- children: undefined,- },{type: "page",name: "OpenUI vs others",diff --git a/docs/lib/docs-navigation.ts b/docs/lib/docs-navigation.tsindex fc99e183c..257127d44 100644--- a/docs/lib/docs-navigation.ts+++ b/docs/lib/docs-navigation.ts@@ -59,7 +59,6 @@ export const DEMOS_URL = "/demos";const promotedGlobalUrls = new Set(["/docs","/docs/getting-started",- "/docs/architecture","/docs/openui-lang/comparison","/docs/mcp","/docs/deploy",@@ -75,11 +74,6 @@ export const GLOBAL_DOCS_TREE: PageTree.Root = {{ type: "separator", name: "Start" },{ type: "page", name: "Introduction", url: "/docs" },{ type: "page", name: "Getting Started", url: "/docs/getting-started" },- {- type: "page",- name: "How OpenUI works",- url: "/docs/architecture",- },{type: "page",name: "OpenUI vs others",diff --git a/docs/next.config.mjs b/docs/next.config.mjsindex df4636999..47d9b6f4b 100644--- a/docs/next.config.mjs+++ b/docs/next.config.mjs@@ -96,6 +96,11 @@ const config = {destination: "/docs/design-system/blocks/accordion",permanent: true,},+ {+ source: "/docs/architecture",+ destination: "/docs",+ permanent: true,+ },{source: "/docs/overview",destination: "/docs",diff --git a/docs/public/images/openui-architecture.svg b/docs/public/images/openui-architecture.svgdeleted file mode 100644index 0359857a3..000000000--- a/docs/public/images/openui-architecture.svg+++ /dev/null@@ -1,149 +0,0 @@-<svg xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 1600 650"- role="img"- aria-labelledby="openui-architecture-title openui-architecture-description"->- <title id="openui-architecture-title">Generation through Gateway</title>- <desc id="openui-architecture-description">- A user request travels from an application to its backend, through OpenUI Gateway, and to a model provider. The corrected OpenUI Lang stream returns to a renderer, which displays the generated interface. Reliability Monitoring tracks generation failures.- </desc>-- <defs>- <linearGradient id="openui-architecture-bg" x1="0" y1="0" x2="1" y2="1">- <stop offset="0" stop-color="#020303" />- <stop offset="0.55" stop-color="#080a0a" />- <stop offset="1" stop-color="#030404" />- </linearGradient>- <radialGradient id="openui-architecture-glow" cx="0.76" cy="0.3" r="0.7">- <stop offset="0" stop-color="#38bdf8" stop-opacity="0.08" />- <stop offset="0.5" stop-color="#8b5cf6" stop-opacity="0.035" />- <stop offset="1" stop-color="#000000" stop-opacity="0" />- </radialGradient>- <linearGradient id="openui-architecture-card" x1="0" y1="0" x2="1" y2="1">- <stop offset="0" stop-color="#242626" stop-opacity="0.9" />- <stop offset="1" stop-color="#111313" stop-opacity="0.96" />- </linearGradient>- <linearGradient id="openui-architecture-phone" x1="0" y1="0" x2="0" y2="1">- <stop offset="0" stop-color="#171919" stop-opacity="0.74" />- <stop offset="1" stop-color="#090a0a" stop-opacity="0.88" />- </linearGradient>- <filter id="openui-architecture-shadow" x="-30%" y="-30%" width="160%" height="160%">- <feDropShadow dx="0" dy="10" stdDeviation="18" flood-color="#000000" flood-opacity="0.55" />- </filter>- <filter id="openui-architecture-soft-glow" x="-30%" y="-30%" width="160%" height="160%">- <feGaussianBlur stdDeviation="10" result="blur" />- <feMerge>- <feMergeNode in="blur" />- <feMergeNode in="SourceGraphic" />- </feMerge>- </filter>- <filter id="openui-architecture-logo-light" color-interpolation-filters="sRGB">- <feFlood flood-color="#e5e7eb" result="logo-color" />- <feComposite in="logo-color" in2="SourceAlpha" operator="in" />- </filter>- <marker id="openui-architecture-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">- <path d="M 0 0 L 10 5 L 0 10 z" fill="#8b9292" />- </marker>- </defs>-- <rect width="1600" height="650" rx="24" fill="url(#openui-architecture-bg)" />- <rect width="1600" height="650" rx="24" fill="url(#openui-architecture-glow)" />-- <g font-family="ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif">- <g filter="url(#openui-architecture-shadow)">- <rect x="35" y="42" width="365" height="565" rx="58" fill="url(#openui-architecture-phone)" stroke="#3f4444" stroke-width="2" vector-effect="non-scaling-stroke" />- <rect x="48" y="55" width="339" height="539" rx="49" fill="none" stroke="#272b2b" stroke-width="1" vector-effect="non-scaling-stroke" />- <rect x="170" y="68" width="94" height="26" rx="13" fill="#242727" />-- <text x="70" y="135" fill="#c8cccc" font-size="24">What did I spend last month?</text>-- <rect x="68" y="165" width="305" height="380" rx="26" fill="url(#openui-architecture-card)" stroke="#333737" stroke-width="1" vector-effect="non-scaling-stroke" />- <text x="92" y="205" fill="#8f9696" font-size="22">Total expenses</text>- <text x="92" y="247" fill="#f4f7f7" font-size="36" font-weight="600">$5,432</text>-- <rect x="94" y="275" width="253" height="240" rx="20" fill="#0d0f0f" stroke="#262929" stroke-width="1" vector-effect="non-scaling-stroke" />- <g transform="rotate(-90 220 388)" filter="url(#openui-architecture-soft-glow)">- <circle cx="220" cy="388" r="66" fill="none" stroke="#7c3aed" stroke-width="62" pathLength="100" stroke-dasharray="30 70" strokeDashoffset="0" />- <circle cx="220" cy="388" r="66" fill="none" stroke="#06b6d4" stroke-width="62" pathLength="100" stroke-dasharray="23 77" strokeDashoffset="-30" />- <circle cx="220" cy="388" r="66" fill="none" stroke="#3b82f6" stroke-width="62" pathLength="100" stroke-dasharray="18 82" strokeDashoffset="-53" />- <circle cx="220" cy="388" r="66" fill="none" stroke="#a855f7" stroke-width="62" pathLength="100" stroke-dasharray="14 86" strokeDashoffset="-71" />- <circle cx="220" cy="388" r="66" fill="none" stroke="#84cc16" stroke-width="62" pathLength="100" stroke-dasharray="15 85" strokeDashoffset="-85" />- </g>- <circle cx="220" cy="388" r="34" fill="#111313" />- <text x="220" y="383" text-anchor="middle" fill="#cfd4d4" font-size="18" font-weight="600">Monthly</text>- <text x="220" y="407" text-anchor="middle" fill="#8d9494" font-size="16">expenses</text>- <text x="120" y="490" fill="#737b7b" font-size="17">Food</text>- <text x="204" y="490" fill="#737b7b" font-size="17">Travel</text>- <text x="292" y="490" fill="#737b7b" font-size="17">Rent</text>- </g>-- <g stroke="#757d7d" stroke-width="1.5" fill="none" vector-effect="non-scaling-stroke">- <path d="M 387 135 H 600" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 770 175 H 900" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 1150 175 H 1260" markerStart="url(#openui-architecture-arrow)" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 1410 265 V 300" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 1200 420 H 770" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 685 460 V 540" markerEnd="url(#openui-architecture-arrow)" />- <path d="M 540 575 H 400" markerEnd="url(#openui-architecture-arrow)" />- </g>-- <g>- <rect x="455" y="111" width="120" height="42" rx="21" fill="#222626" stroke="#343a3a" vector-effect="non-scaling-stroke" />- <text x="515" y="139" text-anchor="middle" fill="#b1b7b7" font-size="20">User query</text>- </g>-- <g filter="url(#openui-architecture-shadow)">- <rect x="600" y="130" width="170" height="330" rx="22" fill="url(#openui-architecture-card)" stroke="#3a4040" stroke-width="1.5" vector-effect="non-scaling-stroke" />- <text x="625" y="175" fill="#f1f4f4" font-size="30" font-weight="500">Backend</text>- <text x="625" y="210" fill="#858d8d" font-size="22">Data and logic</text>- <rect x="652" y="405" width="46" height="11" rx="5.5" fill="#7f8787" />- <rect x="652" y="425" width="46" height="11" rx="5.5" fill="#525959" />- </g>-- <g filter="url(#openui-architecture-shadow)">- <rect x="900" y="125" width="250" height="145" rx="22" fill="url(#openui-architecture-card)" stroke="#54505f" stroke-width="1.5" vector-effect="non-scaling-stroke" />- <text x="925" y="170" fill="#d8d3ff" font-size="30" font-weight="600">Gateway</text>- <text x="925" y="207" fill="#9993ae" font-size="20">Route and failover</text>- <text x="925" y="239" fill="#9993ae" font-size="20">Correct model output</text>- </g>-- <g filter="url(#openui-architecture-shadow)">- <rect x="1260" y="60" width="300" height="205" rx="26" fill="url(#openui-architecture-card)" stroke="#404545" stroke-width="1.5" vector-effect="non-scaling-stroke" />- <rect x="1278" y="78" width="264" height="169" rx="19" fill="none" stroke="#343939" stroke-width="1" vector-effect="non-scaling-stroke" />- <text x="1295" y="120" fill="#f1f3f3" font-size="30" font-weight="500">Model providers</text>- <text x="1295" y="155" fill="#858c8c" font-size="20">Models across providers</text>- <image href="/brand-icons/openai.svg" x="1292" y="188" width="36" height="36" filter="url(#openui-architecture-logo-light)" aria-label="OpenAI" />- <image href="/brand-icons/anthropic.svg" x="1350" y="188" width="36" height="36" filter="url(#openui-architecture-logo-light)" aria-label="Anthropic" />- <image href="/brand-icons/gemini.svg" x="1408" y="188" width="36" height="36" filter="url(#openui-architecture-logo-light)" aria-label="Google Gemini" />- <image href="/brand-icons/meta.svg" x="1466" y="188" width="36" height="36" filter="url(#openui-architecture-logo-light)" aria-label="Meta" />- </g>-- <text x="835" y="130" text-anchor="middle" fill="#a7adad" font-size="20">Components</text>- <text x="835" y="156" text-anchor="middle" fill="#a7adad" font-size="20">and context</text>- <text x="1205" y="130" text-anchor="middle" fill="#a7adad" font-size="20">Route</text>- <text x="1205" y="156" text-anchor="middle" fill="#a7adad" font-size="20">and failover</text>-- <g filter="url(#openui-architecture-shadow)">- <rect x="1200" y="300" width="360" height="250" rx="28" fill="url(#openui-architecture-card)" stroke="#48404f" stroke-width="1.5" vector-effect="non-scaling-stroke" />- <rect x="1220" y="320" width="320" height="210" rx="20" fill="none" stroke="#3c3541" stroke-width="1" vector-effect="non-scaling-stroke" />- <text x="1245" y="365" fill="#f1eafb" font-size="32" font-weight="500">OpenUI Lang</text>- <text x="1245" y="402" fill="#94899d" font-size="22">Compact interface format</text>- <text x="1245" y="458" fill="#a89dae" font-size="24" font-family="ui-monospace, SFMono-Regular, Menlo, monospace">root = Stack(...)</text>- <text x="1245" y="496" fill="#807785" font-size="24" font-family="ui-monospace, SFMono-Regular, Menlo, monospace">chart = PieChart(...)</text>- </g>-- <text x="1015" y="365" text-anchor="middle" fill="#c1b8c8" font-size="22">Corrected OpenUI Lang stream</text>- <text x="1015" y="393" text-anchor="middle" fill="#827a88" font-size="19">compact and stream-friendly</text>-- <g filter="url(#openui-architecture-shadow)">- <rect x="540" y="540" width="300" height="70" rx="18" fill="url(#openui-architecture-card)" stroke="#3f5b5d" stroke-width="1.5" vector-effect="non-scaling-stroke" />- <text x="690" y="584" text-anchor="middle" fill="#bcecf0" font-size="26" font-weight="500">OpenUI Lang renderer</text>- </g>-- <g>- <path d="M 890 590 H 1570" stroke="#fb7185" stroke-opacity="0.38" stroke-width="1.5" stroke-dasharray="5 7" fill="none" vector-effect="non-scaling-stroke" />- <rect x="970" y="555" width="300" height="70" rx="18" fill="#fb7185" fill-opacity="0.1" stroke="#fb7185" stroke-opacity="0.45" vector-effect="non-scaling-stroke" />- <text x="1120" y="599" text-anchor="middle" fill="#fda4af" font-size="24" font-weight="500">Reliability Monitoring</text>- </g>- </g>-</svg>diff --git a/docs/public/videos/openui-introduction-poster.jpg b/docs/public/videos/openui-introduction-poster.jpgnew file mode 100644index 000000000..78ddb0e1fBinary files /dev/null and b/docs/public/videos/openui-introduction-poster.jpg differdiff --git a/docs/public/videos/openui-introduction.mp4 b/docs/public/videos/openui-introduction.mp4new file mode 100644index 000000000..9ba243a5cBinary files /dev/null and b/docs/public/videos/openui-introduction.mp4 differdiff --git a/docs/source.config.ts b/docs/source.config.tsindex 5c833e767..a7fbd18ef 100644--- a/docs/source.config.ts+++ b/docs/source.config.ts@@ -5,6 +5,8 @@ import { z } from "zod";const docsPageSchema = pageSchema.extend({customHeader: z.boolean().optional().default(false),+ // Hides the previous/next page links at the bottom of the page.+ hideFooter: z.boolean().optional().default(false),});// You can customise Zod schemas for frontmatter and `meta.json` herediff --git a/packages/server/README.md b/packages/server/README.mdindex 0663cbec5..6111c087a 100644--- a/packages/server/README.md+++ b/packages/server/README.md@@ -47,7 +47,7 @@ const model = new OpenAI();export async function POST(request: Request) {const { messages } = await request.json();const source = await model.chat.completions.create(- { model: "openai/gpt-5.5", messages, stream: true },+ { model: "gpt-5.5", messages, stream: true },{ signal: request.signal },);