Most AI chatbots still answer in paragraphs. You ask a model to compare quarterly revenue by region and you get a wall of text with a markdown table buried in it — static, unfilterable, and already out of date the moment it renders. OpenUI exists to end that: it is a framework that lets a model answer with a real interface instead — a chart you can hover, a table you can sort, a form you can fill in, rendered progressively as the tokens arrive. It has been around since December 2024, but this week it is the project everyone is starring: OpenUI is the third-most-starred repository on GitHub today, with 222 new stars in the last day, 17,144 stars in total, and fresh releases of its two core packages — @openuidev/[email protected] and @openuidev/[email protected] — published on December 4.

The idea is simple and, in practice, hard to get right. You define the components your model is allowed to generate — charts, tables, forms, cards — and OpenUI turns that component library into a system prompt. The model replies in OpenUI Lang, a compact language designed for streaming, and the renderer draws the interface piece by piece as the response arrives. The token claim is the part that makes engineers stop scrolling: OpenUI Lang uses up to 67% fewer tokens than equivalent JSON, and the project’s own benchmark, measured with tiktoken on the GPT-5 encoder across seven UI scenarios, totals 4,800 tokens against 10,180 for Vercel’s JSON-Render format and 9,948 for Thesys’s own C1 JSON — a 52.8% and 51.7% saving respectively. This tutorial takes you from zero to a working app: scaffold it, inspect the generated spec, then build a Recipe Remix agent that reads a pantry, searches for real recipes, and renders three recipe cards you can actually click.

What you’ll need

Node.js 20 or later and npm — nothing else to install by hand. No GPU, no local model, no Docker. The scaffold runs entirely on your machine, and the model calls go through the Thesys Gateway, OpenUI’s hosted OpenAI-compatible endpoint. You need a free gateway key before the chat step: the CLI mints one with openui generate-api-key, which opens a browser sign-in to Thesys. The free tier includes models such as google/gemini-3.6-flash-free, which is the scaffold’s default, so the whole tutorial costs nothing. Everything before the key step — scaffolding, installing, generating the spec — needs no account at all.

One thing to know before you start: OpenUI’s own quickstart documents a “Gateway-backed starter” whose chat route is built around a tool loop and a generateSystemPrompt call inline in the route. The starter the CLI actually scaffolds today — version 0.6.3, LangGraph backend — wires those same pieces together differently, in a file called src/agent.ts. The quickstart’s diffs do not apply to it. This tutorial is written against the scaffold the CLI produces, not the docs’ version of it, and the differences are called out where they matter.

Step 1: Scaffold the app

Run the CLI. It asks nothing when you pass --no-interactive, and it needs no account or key to scaffold:

npx @openuidev/cli@latest create --name recipe-remix --no-interactive --no-immediate

The flags: --no-interactive takes the defaults for everything not passed on the command line, and --no-immediate installs dependencies without starting the dev server. The default backend framework is LangGraph; the other options are the Vercel AI SDK and Eve, selectable with --backend-framework. The command prints ✓ Scaffolded and then installs dependencies. What lands on disk is a Next.js 16 app with React 19, a LangGraph agent, and the OpenUI packages already wired in. In the sandbox run for this tutorial the CLI’s install step failed with an npm write error — a disk-quota problem in that sandbox, not a package problem — and a plain npm install inside the project fixed it. On a normal machine the scaffold installs cleanly. Expect roughly 820 MB of node_modules.

The scaffold pins @openuidev/lang-core and @openuidev/react-lang at 1.1.1, while 1.2.1 shipped on December 4. The pinned versions are the ones this tutorial was built against; if you want the newest release, run npm install @openuidev/lang-core@latest @openuidev/react-lang@latest after scaffolding.

Step 2: Inspect what you got

Before changing anything, look at the three files that do the work. First, src/lib/library.ts — the entire component library, in one line:

/** Entry point for `openui generate src/lib/library.ts --spec`, which writes both exports to `src/generated/spec.json`. */
export { library, promptOptions } from "@openuidev/intelligent-ui-library";

Second, src/agent.ts, where the agent is assembled. It imports the generated spec, splits off its prompt options, and builds the system prompt from the library itself:

import { generateSystemPrompt } from "@openuidev/lang-core";
import librarySpec from "./generated/spec.json";

const { promptOptions, ...library } = librarySpec;

/** LangGraph owns the tool loop; OpenUI Cloud provides Chat Completions. */
export const graph = createAgent({
  model: cloudModel(DEFAULT_MODEL),
  tools: [getWeather],
  systemPrompt: generateSystemPrompt({ cloud: true, library, promptOptions }),
  stateSchema: CloudAgentState,
  middleware: [selectedModel, persistTurn],
});

The model is LangChain’s ChatOpenAI pointed at https://api.thesys.dev/v1/embed with a THESYS_API_KEY environment variable — a standard OpenAI-compatible client, so the gateway is a configuration choice rather than a lock-in. The default model is google/gemini-3.6-flash-free, and the model switcher in the UI offers free “Included” models alongside Claude Sonnet 5, Opus 4.7, and GPT-5.5.

Third, src/components/cloud-chat.tsx, which renders the chat. It hands the component library to the renderer as componentLibrary={library}, imported from @openuidev/intelligent-ui-library — not from src/lib/library.ts. That distinction matters in Step 5: when you add your own component, you change the import here as well as the library file.

Step 3: Generate the component spec

Run the generate script, which the scaffold defines as openui generate src/lib/library.ts --spec --out src/generated/spec.json:

cd recipe-remix
npm run generate

It exits cleanly and writes a 127 KB spec.json describing roughly fifty components, each with a typed signature and a one-line description the model will see. A few entries from the real file:

Chart:  Chart(type: "bar" | "line" | "area" | "pie" | "donut" | "scatter",
        data: Record<string, string | number>[], x?: string, series?: string[],
        format?: "number" | "percent", stacked?: boolean, height?: number)
Table:  Table(columns: string[], rows: any[][])
Form:   Form(children: Node[])
Button: Button(label: string, action?: ActionExpression,
        variant?: "solid" | "outline" | "soft" | "ghost",
        color?: "primary" | "danger" | "success", size?: "sm" | "md" | "lg")

This file is the contract between your code and the model. The system prompt is generated from it, so the model can only emit components that exist here, with props that typecheck against these signatures. Regenerate it whenever the library changes — the dev server runs it automatically as a predev step, but running it by hand now proves the pipeline works before you touch anything. The spec also carries promptOptions, which generateSystemPrompt consumes alongside the library.

Diagram of the OpenUI pipeline: a component library becomes a system prompt, the model streams OpenUI Lang, and the renderer assembles the interface
OpenUI pipeline: component library to system prompt to streamed interface. Illustration: AI Frontier Post.

That is the whole mechanism, and it is worth stating plainly because it explains both the strengths and the limits. The model never writes React code and never touches the DOM. It emits a compact, structured description of an interface, and your renderer — with your components, your styles, your event handlers — draws it. A malformed or hallucinated component name cannot inject arbitrary markup, because the parser only recognises what the library defines. The price is that the model can only build what you defined: OpenUI is a way to let a model compose your interface, not a way to let it invent one.

Step 4: Add a pantry tool

The scaffold ships with one example tool, get_weather, which looks up the weather through Open-Meteo — free, no key. It is the reference pattern for adding your own: a metadata declaration the model sees, and an executor that runs on your server. Create src/lib/tools/get-recipe-profile.ts with the pantry tool from the official quickstart:

export const getRecipeProfileTool = {
  type: "function" as const,
  name: "get_recipe_profile",
  description:
    "Read the cook's pantry and recipe preferences. Call this before recommending pantry recipes.",
  parameters: {
    type: "object",
    properties: {},
    required: [],
    additionalProperties: false,
  },
  strict: true,
};

export async function executeGetRecipeProfile(): Promise<string> {
  return JSON.stringify({
    pantry: ["black beans", "corn", "canned tomatoes", "rice", "cheddar"],
    diet: "vegetarian",
    cuisine: "American",
    maxMinutes: 30,
    servings: 2,
  });
}

Change the values in executeGetRecipeProfile() to match your own kitchen — the point is that the tool returns structured facts the model must use, instead of the model guessing what you have. Now wire it into the agent. In src/agent.ts, the weather tool is wrapped with LangChain’s tool() helper and registered in the createAgent call; follow that exact pattern. Add the import:

import { executeGetRecipeProfile, getRecipeProfileTool } from "./lib/tools/get-recipe-profile";

Add the wrapper beside getWeather:

const getRecipeProfile = tool(
  async () => executeGetRecipeProfile(),
  {
    name: "get_recipe_profile",
    description: getRecipeProfileTool.description,
    schema: z.object({}),
  },
);

And register it:

tools: [getWeather, getRecipeProfile],

Note what the quickstart does differently: its version of this step edits a tools array and a functionTools map inside the chat route. Those do not exist in this scaffold — the tool loop lives in LangGraph, and agent.ts is the only place tools are registered. If you follow the docs literally here, your edits will land in files that do not contain the lines they describe.

Step 5: Add the RecipeRemix component

This is the step that turns the chatbot into an interface. Create src/lib/recipe-library.tsx with a custom component, taken from the official quickstart. It defines one component, RecipeRemix, with a Zod schema for its props — an array of recipes, each with a title, time, servings, ingredients, a source URL, and an optional image URL — and renders three recipe cards in a grid, each with a “Source” link and a “Remix this” button that sends a follow-up message to the assistant:

import { createLibrary, defineComponent, useTriggerAction } from "@openuidev/react-lang";
import { openuiLibrary } from "@openuidev/react-ui";
import { z } from "zod/v4";

const cardStyle = {
  display: "grid",
  gridTemplateRows: "120px auto 66px 1fr auto",
  gap: 8,
  height: "100%",
  padding: 12,
  border: "1px solid #e5e7eb",
  borderRadius: 12,
} as const;

const RecipeRemix = defineComponent({
  name: "RecipeRemix",
  description: "Three sourced recipe suggestions.",
  props: z.object({
    recipes: z.array(
      z.object({
        title: z.string(),
        time: z.string(),
        servings: z.number().int().positive(),
        ingredients: z.array(z.string()),
        sourceUrl: z.string(),
        imageUrl: z.string().optional(),
      }),
    ),
  }),
  component: function RecipeRemix({ props }) {
    const triggerAction = useTriggerAction();
    return (
      <section style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: 12, width: "100%" }}>
        <h2 style={{ gridColumn: "1 / -1", margin: 0, fontSize: 24, fontWeight: 600 }}>Recipe Remix</h2>
        {props.recipes.map((recipe) => (
          <article key={recipe.title} style={cardStyle}>
            <div style={{ overflow: "hidden", borderRadius: 8, background: "#f3f4f6" }}>
              {recipe.imageUrl?.startsWith("https://") && (
                <img src={recipe.imageUrl} alt={recipe.title}
                  onError={(event) => (event.currentTarget.hidden = true)}
                  style={{ display: "block", width: "100%", height: "100%", objectFit: "cover" }} />
              )}
            </div>
            <div style={{ display: "flex", gap: 6 }}>
              <span style={{ padding: "2px 8px", borderRadius: 999, background: "#eff6ff", color: "#1d4ed8" }}>{recipe.time}</span>
              <span style={{ padding: "2px 8px", borderRadius: 999, background: "#f3f4f6" }}>Serves {recipe.servings}</span>
            </div>
            <h3 style={{ margin: 0 }}>{recipe.title}</h3>
            <div>
              <strong>Ingredients</strong>
              <ul style={{ margin: 0, paddingLeft: 20, fontSize: 14 }}>
                {recipe.ingredients.map((ingredient) => (
                  <li key={ingredient}>{ingredient}</li>
                ))}
              </ul>
            </div>
            <div style={{ display: "flex", alignItems: "center", gap: 8, marginTop: "auto" }}>
              <a href={recipe.sourceUrl} target="_blank" rel="noreferrer"
                style={{ padding: "5px 8px", borderRadius: 8, fontSize: 13, fontWeight: 600, textDecoration: "none", border: "1px solid #d1d5db", color: "#111827" }}>
                Source ↗
              </a>
              <button
                style={{ padding: "5px 8px", borderRadius: 8, fontSize: 13, fontWeight: 600, border: 0, background: "#111827", color: "white" }}
                onClick={() => triggerAction(`Make ${recipe.title} faster and simpler`)}
              >
                Remix this
              </button>
            </div>
          </article>
        ))}
      </section>
    );
  },
});

export const recipeLibrary = createLibrary({
  root: openuiLibrary.root ?? "Stack",
  componentGroups: openuiLibrary.componentGroups,
  components: [...Object.values(openuiLibrary.components), RecipeRemix],
});

Two details are doing real work here. First, the props are a Zod schema, so the model’s output is validated against types before it renders — a recipe without a title or with a negative serving count never reaches the screen. Second, useTriggerAction() is how a generated component talks back: the “Remix this” button sends a new message to the agent, so the interface is interactive in both directions rather than a dead render. The library extends the standard openuiLibrary, so every built-in component stays available alongside RecipeRemix.

Now point the scaffold at the new library. In src/lib/library.ts, replace the re-export with:

export { recipeLibrary as library } from "./recipe-library";
export { promptOptions } from "@openuidev/intelligent-ui-library";

Then regenerate the spec so the model learns about RecipeRemix:

npm run generate

And in src/components/cloud-chat.tsx, change the renderer’s import so it uses your library instead of the stock one:

import { ThemeProvider } from "@openuidev/intelligent-ui-library";
import { recipeLibrary } from "@/lib/recipe-library";
// ...
componentLibrary={recipeLibrary}

Finally, give the model its instructions. In src/agent.ts, pass them into the prompt generation, using the instructions option the quickstart documents:

const recipeInstructions = `
You are a practical recipe remix assistant.
Use web search before recommending recipes and include real source URLs.
Use image search to include a relevant recipe image when available.
For each recipe, set imageUrl to an HTTPS URL returned by image search when available.
Call get_recipe_profile when the user asks what they can cook from their pantry.
Use the profile's servings value for every recipe.
Return exactly three concise recipes and clearly label substitutions.
Render the final recipe recommendations using exactly one RecipeRemix component.
Do not return recipe recommendations as a prose-only response.
Never claim that a recipe is allergen-safe.
`;

systemPrompt: generateSystemPrompt({
  cloud: true,
  library,
  promptOptions,
  instructions: recipeInstructions,
}),

While you are here, replace the starters in src/lib/starters.tsx with the quickstart’s three — “Cook from my pantry”, “Find a high-protein dinner”, “Remix a comfort food” — and change the welcome title in cloud-chat.tsx from “What’s on your mind today?” to “Recipe Remix”. The scaffold passes starters through a starters prop, not the promptTemplates prop the quickstart’s diff mentions, so that part of the docs’ diff does not apply either.

Three recipe cards rendered inside a chat window, each with a food photo, a time badge, and an ingredient list
What the finished agent renders: three recipe cards inside the chat, not a wall of text. Illustration: AI Frontier Post.

Step 6: Mint a key and try it

Generate the gateway key and start the dev server:

npx @openuidev/cli@latest generate-api-key
npm run dev

generate-api-key opens a browser sign-in to Thesys and writes the key to your project’s .env file — keep it on the server and never expose it to browser code, as the docs warn. The dev server runs on http://localhost:3000. Click Cook from my pantry. The agent should call get_recipe_profile, search for recipes, and render three recipe cards. Click Remix this on any card to start a follow-up turn. If the model answers in prose instead of cards, the usual cause is a stale spec: re-run npm run generate and restart the dev server, since the spec is read when the agent starts.

When to use OpenUI vs the alternatives

Generative UI now has several competing answers, and OpenUI’s own README compares them head-on. On its benchmark, OpenUI Lang uses roughly a third of the tokens of the JSON formats — 4,800 tokens against 10,180 for Vercel’s JSON-Render and 9,948 for C1 JSON across the same seven scenarios — and renders the first UI in 4.9 seconds at 60 tokens per second, against 14.2 seconds for the JSON approaches and around 20 for CopilotKit’s OpenGenUI. It is the only one of the four with built-in data fetching and a chat UI included, and it covers web, mobile, email, and video surfaces. The trade is scope: A2UI, Google’s protocol, is the interop play — if you need agents from different vendors to render into each other’s surfaces, a protocol matters more than a language, and OpenUI itself ships an @openuidev/a2ui package for exactly that. Vercel’s AI SDK is the path of least resistance if you already live on Vercel. CopilotKit is a fuller copilot framework rather than a UI language. Choose OpenUI when the interface is the product — a dashboard, a configurator, a report — and you want the model to compose it from components you control, with the token bill to match. Choose a protocol when the interface has to cross organisational boundaries.

Two more things worth knowing before you commit. First, OpenUI is framework-agnostic at the core: @openuidev/lang-core has no React, Vue, Svelte, or Angular dependency, and first-party runtimes exist for all four, plus a browser bundle for CDN or iframe embeds with no build step. Second, there is an agent skill for it — npx skills add thesysdev/skills --skill openui — which teaches Claude Code, Codex, Cursor, or Copilot how to scaffold, build, and debug OpenUI apps, including how to fix malformed model output. That is the fastest way to keep the workflow in your editor rather than in the docs.

What was verified, and what wasn’t

Steps 1 to 3 were run verbatim in a sandbox for this tutorial: the CLI scaffolded the app, the dependencies installed, and npm run generate produced the 127 KB spec quoted above, with the component signatures copied from the generated file. The scaffold’s wiring — src/agent.ts, src/lib/library.ts, src/components/cloud-chat.tsx — was read from the scaffold the CLI produced, and the places where the official quickstart disagrees with that scaffold are called out in the text. Steps 4 and 5 follow the project’s own quickstart code, adapted to the scaffold’s actual files; those edits were not compiled or run in the sandbox, and the live chat in Step 6 was not run either, because it needs a Thesys gateway key tied to a reader’s own account. If you hit a snag in those steps, the first things to check are the spec (regenerate it) and the library import in cloud-chat.tsx — those are the two places where the docs and the scaffold diverge.

The takeaway

OpenUI’s pitch is that the chat window is the wrong shape for most of what models are asked to do, and the fix is not a better chatbot but a smaller language for interfaces. The evidence for taking it seriously is not the star count — it is the mechanism: a typed component library, a generated system prompt, a streaming renderer, and a token format that costs roughly half what JSON costs. The cost of adopting it is one scaffold command and a free key. Start with the default starter, read src/agent.ts before you trust the quickstart, and build one component that solves a real problem for your users — a recipe card, a quote builder, a status board. The moment the model answers with something you can click instead of something you have to read, the idea stops being a demo.

Sources: the OpenUI repository (github.com/thesysdev/openui), the OpenUI documentation (openui.com), and the project’s OpenUI Lang quickstart. Star counts and release dates are as observed on December 4, 2026. Steps 1–3 were run in a sandbox for this tutorial; Steps 4–6 follow the official quickstart adapted to the scaffold the CLI produces, as described in the verification note above.