thesysdev/openui is an MIT-licensed Generative UI framework (about 18.4k stars per the GitHub API on 2026-12-06). I read the checkout at commit 73b7d49, where @openuidev/lang-core is version 1.2.1. The README describes OpenUI Lang as “a compact, streaming-first language for model-generated UI” and claims up to 67% fewer tokens than JSON, based on its own benchmarks/ folder. I did not re-run those benchmarks. What I did run is the core package, with a tiny library and a streaming parser, described below.
Companion tutorial: how to use it is on Cui.Guru: Let your model draw the UI with OpenUI.
The workflow in motion
Architecture
The repo is a pnpm workspace. packages/lang-core is the framework-agnostic layer (parser, prompt generation, runtime evaluation, types). react-lang, vue-lang, svelte-lang and angular-lang wrap it with a renderer, and react-ui adds prebuilt chat layouts and the default openuiLibrary. The spec in spec/ describes the roles: the model writes the language, the client parses and renders it, and the host (your app) calls the model and provides tools.
The diagram summarizes exported types (DefinedComponent, Library, PromptOptions in packages/lang-core/src/library.ts, and the RendererProps interface behind Renderer in packages/react-lang/src/Renderer.tsx), reduced to the fields that matter here.
The core design idea
One definition drives three things: what the model is told, what the parser accepts, and what the renderer draws. You write a component once with a Zod schema, a description and a renderer. defineComponent in lang-core is deliberately thin:
// packages/lang-core/src/library.ts (condensed; return type and ref cast omitted)
export function defineComponent<T extends z.$ZodObject, C>(config: {
name: string; props: T; description: string; component: C;
}) {
assertV4Schema(config.props, config.name);
tagPromptName(config.props, config.name);
return { ...config, ref: config.props };
}
createLibrary then registers each schema, rejects a root that is not a defined component, and rejects function or action names that collide with built-ins, components, functions or previously registered actions. Its prompt() turns every schema into a signature line via schemaSignature and hands the spec to generatePrompt:
// packages/lang-core/src/library.ts (condensed)
prompt(options?: PromptOptions): string {
const spec: PromptSpec = {
root: input.root,
components: buildComponentSpecs(componentsRecord, reg),
componentGroups: input.componentGroups,
...callSpecs(),
...options,
};
return generatePrompt(spec);
},
I ran this with two components (Card with a children array and Metric(label, value)). The generated prompt came to 2,449 characters and contained the lines Card(children: any[]) — Container and Metric(label: string, value: number) — One KPI. Arguments are positional, so the prop order in your Zod object is the wire format. The spec’s section 3 turns that into library rules: add props only at the end, never reorder or remove, and give a new required prop a default so stored programs keep rendering.
The language side is equally deliberate. A program is one name = value per line, names may be used before they are defined, and rendering starts at root. Because the first line gives the layout and later lines fill it in, once the root statement is recognizable an incomplete prefix still renders a usable partial page. The prompt generator reflects that: its steps include “root = Card(...) — UI shell appears immediately”. With the streaming parser I fed three chunks, split mid-statement:
// my test script, @openuidev/lang-core 1.2.1
const sp = createStreamingParser(lib.toJSONSchema(), "Card");
sp.push('root = Card([a,'); // children: []
sp.push('b])\na = Metric("Open", 12)\nb = Metr'); // children: [{label:"Open", value:12}]
sp.push('ic("Closed", 8)'); // children: both metrics
The root rendered an empty list at first, then one metric, then two, with no errors reported along the way. The partial token Metr simply was not resolved yet.
Recovery is a policy, not an exception. The spec’s error table says an unknown-component drops the component and a missing-required prop is filled from the schema default if there is one, otherwise the component is dropped. I parsed root = Card([a,b]) where b = PieChart("x") is not in the library. The result kept the valid metric and returned (selected fields):
{ "code": "unknown-component", "component": "PieChart", "statementId": "b",
"message": "Unknown component \"PieChart\" — not found in catalog or builtins. Available components: Card, Metric" }
The message names the available components, so it can be sent back to the model for a one-line fix. Follow-ups use the same trick. In an editing surface the model sends only changed statements, and mergeStatements in parser/merge.ts replaces by name, treats name = null as a delete, and garbage-collects anything unreachable from root (keeping $ state variables):
// packages/lang-core/src/parser/merge.ts
if (stmt.ast.k === "Null") {
// `name = null` in a patch means "delete this statement"
merged.delete(stmt.id);
...
}
Running mergeStatements('root = Card([a])\na = Metric("Open", 12)', 'a = Metric("Open", 13)\nz = Metric("x",1)') returned the program with a updated and z removed, because nothing reachable from root used it.
Beyond layout, the language is a small reactive runtime: $ variables for state, Query and Mutation calls against tools the host provides (a function map or an MCP-style client through toolProvider), built-ins such as @Filter, @Sort and @Each, and actions such as @ToAssistant that become events for the host. All of that runs in the client, so a filter change does not need another model call.
I did not run the React renderer, the CLI scaffold or any model call, and I did not read the Vue, Svelte, Angular or Swift runtimes.
Takeaways
- Define the model’s vocabulary once (schema, description, renderer) and derive the prompt from it, so prompt and parser cannot drift.
- Make the output format incremental by construction: a layout-first, hoisting language beats a JSON tree that is invalid until the last brace.
- Treat model mistakes as expected input: drop the smallest broken piece, keep rendering, and return a structured error the model can act on.
- Patch by name instead of regenerating the page; deletion and garbage collection fall out of a simple rule.
- Keep stored output stable with append-only prop order.
Want generative UI wired safely into your product? Get in touch at cui.guru/contact.
Click to load Disqus comments