ChatGPT's widgets aren't web pages.
I took the app apart to see how it draws them, then rebuilt the idea as an open SDK.
Ask ChatGPT on an iPhone for a tip calculator and you get one: real sliders, real text fields, numbers that change as you drag. I assumed it was a web page in a frame, like every other AI widget. It isn't. The model writes a small program, and the app draws it with native views, using Snap's open-source Valdi.
This post is what I found inside ChatGPT, and Prism, the SDK I built so any app can do the same.
Three ways to put UI in a chat
Ask how AI apps show UI and the usual answer is: a web page in a sandbox. That's how ChatGPT apps from other companies work. They're built on MCP Apps, a shared standard that Claude and VS Code also support: a tool returns an HTML page, and the chat loads it in a locked-down iframe. Claude artifacts work the same way, and Gemini's dynamic view writes a whole web app for one prompt.
That's one of three approaches:
| Web code | Named parts | Code, drawn natively | |
|---|---|---|---|
| Who | MCP Apps, Claude artifacts, Gemini | Google A2UI, Vercel json-render | ChatGPT's own answers, Prism |
| Model sends | HTML / JS | JSON | Small JSX program |
| Drawn by | iframe / web view | The app | The app |
| Logic on screen | Yes | Little | Yes |
| Feels like | A web page | The app | The app |
Most people only know the first. ChatGPT's own answers use the third.
No web engine was running
In October 2026 I looked at ChatGPT from three sides: the Mac app, taken apart with REA and Ghidra; the live system log of an iPhone running ChatGPT; and chatgpt.com in Chrome.
The iPhone log gave it away. When a third-party widget opened, a web view started up and took about 158 MB. When ChatGPT drew its own counter, no web engine ran at all.
The reason is inside the app. In a part called OpenAIXPlat, ChatGPT ships Valdi, Snap's open-source framework for building real native screens with TypeScript. It can even download new Valdi code later, without an app update.
| Where | Drawn with |
|---|---|
| iPhone | Native views, using Snap's Valdi |
| chatgpt.com | React, straight into the page |
| Mac app | The same React code, since the new Mac app is Electron |
| Third-party widgets | A web view |
The model writes a program, not a page
Four steps take a reply from the model to your screen:
1The model writes code, not JSON
Inside its normal Markdown reply, the model writes state lines and JSX-style tags. OpenAI calls this format DIL.
2The server compiles it
Before it reaches your phone, OpenAI's server turns that into plain JavaScript and ships it in one message, model_dil_v2. Here is a counter from a real reply, before and after:
{@body const [count,setCount] = DIL.useState(0)}
<box background={dark?"#10121B":"#F3F5FA"} radius="xl" padding={3}>
<title size="2xl">{count}</title>
<text size="sm">Counter state</text>
<row gap={2}>
<button onClick={()=>setCount(count-1)}><icon name="minus"/></button>
<button onClick={()=>setCount(count+1)}><icon name="plus"/></button>
</row>
</box>const [count, setCount] = DIL.useState(0, { key: "count" });
__dilSafe(() => __dil.jsx("text", { size: "sm" }, __dilConstants["12"]), null),
__dilSafe(() => __dil.jsx("button",
{ onClick: () => setCount(count + 1) },
__dil.jsx("icon", { name: "plus" })
), null)- Every part is wrapped in
__dilSafe, so if one part crashes, only that part disappears. - The words live apart from the code, in a separate
constantslist. The code only points at them. - Every piece of state gets a name (
key: "count"), so the server can save it. Come back later and the counter still says 7. - A plain Markdown version travels along, for anything that can't draw the widget.
- Mistakes are fixed, not fatal. In my sample the model used a
<span>, which isn't a DIL part. The compiler dropped it and wrote down why.
3A hidden sandbox runs it
On chatgpt.com there's one invisible iframe for the whole page, allowed to run scripts and nothing else. Inside it a Web Worker runs the model's code. A tap goes in as a small message ("run callback 62"), and the whole updated screen comes back out as a tree.
4The app draws the tree with its own parts
On iPhone that means native views through Valdi. On the web it's React, and the Mac app reuses the same React code.
What I still don't know: exactly how the iPhone turns the tree into Valdi views (App Store protection hides the code), whether short text replies go through it too, and Android, which I didn't check.
Code carries logic. JSON can't.
Sending JSON only describes a layout. A counter, a checklist that counts what's done, a quiz that marks your answer: all of these need logic. With JSON, every tap goes back to the model or needs a special component.
Sending code carries the logic. Tap +1 and the number changes on the phone, with no round trip. And because the app draws the result with its own parts, it still looks, scrolls and feels like the app. The sandbox keeps the code away from everything else.
The same idea, for any app
ChatGPT keeps all of this to itself. I wanted it for my own apps, and finding Valdi inside ChatGPT is what gave me the idea:
If Valdi can draw OpenAI's answers natively, it can draw anyone's.
So Prism keeps ChatGPT's design. The model writes JSX with useState inside a normal answer. A server compiler checks it, fixes what it can and adds a Markdown backup. Every part is wrapped, the words are kept apart from the code, and the state comes back after every tap, so the app can save it and restore the screen later. Here is the same counter in both:
{@body const [count,setCount] = DIL.useState(0)}
<box background={dark?"#10121B":"#F3F5FA"} radius="xl" padding={3}>
<title size="2xl">{count}</title>
<text size="sm">Counter state</text>
<row gap={2}>
<button onClick={()=>setCount(count-1)}><icon name="minus"/></button>
<button onClick={()=>setCount(count+1)}><icon name="plus"/></button>
</row>
</box>const [count, setCount] = useState(0)
<Card title="Counter">
<Stat label="Count" value={count} />
<Text secondary>{count === 0 ? "Tap a button" : count > 0 ? "Going up" : "Going down"}</Text>
<Row tight>
<Button onPress={() => setCount(count - 1)}>-1</Button>
<Button main onPress={() => setCount(count + 1)}>+1</Button>
<Button danger disabled={count === 0} onPress={() => setCount(0)}>Reset</Button>
</Row>
</Card>The model says what. The app decides how.
In ChatGPT the model writes hex colours into the code, like #10121B. That works when the model and the app come from the same company. Prism goes into other people's apps, so the model only says what something means: main, danger. The app's design tokens decide what it looks like, in light and dark.
| ChatGPT (DIL) | Prism | |
|---|---|---|
| Looks | The model picks colours | Meaning only. The app's design decides. |
| Hooks | 13, including useEffect and useNow | Only useState |
| Syntax | JSX mixed with Svelte-style {#each} | Plain JSX and .map |
| Parts | About 45, all drawn by the app | 39 parts that expand into 15 basic blocks. New parts can ship from the server. |
| Real actions | Open a link, copy, send a message and a few more | The same, plus actions behind a <Confirm> tap |
| Models | OpenAI's | Any: inline, or as a tool for Anthropic, OpenAI or MCP |
The model learns all of this from one prompt, built from the part catalog. Four rules do most of the work:
- Only meaning, never looks. No colours, sizes, spacing or fonts.
- Only useState. No other hooks, no fetch, no timers, no window.
- Leave the screen through P.
P.asksends a message as the user.P.open,P.copyandP.toastdo what they say. - Only parts from the list. Card, Stat, Quiz, Choice, Carousel, Steps, Chart, Confirm and the rest.
From text to native views
- Compile on the server. Babel reads the block, turns each
useStateinto a state box, checks every part and prop against the catalog, and turns tags into plain calls. - Ship an envelope. JSON with the compiled code, the starting state, the words, the parts it uses and a Markdown backup.
- Run it in a sandbox. One small runtime file runs on every platform. It only takes and returns text:
load(id, envelope)andevent(id, handler, value), which give back the new tree. - Draw 15 blocks. The 39 parts expand into box, text, image, button, switch, slider, input, chart and a few more. Each platform only draws those 15.
See the counter after Prism's compiler
P.screen(function (S, T) {
const count = S.count;
const setCount = function (v) { P.tick(); S.count = v; };
return P.el("Card", "n0", { title: T[2] }, [
P.safe("n1", () => P.el("Text", "n1", null, [T[0], count])),
P.safe("n2", () => P.el("Button", "n2", {
onPress: P.on("h0", () => (P.tick(), setCount(count + 1)))
}, [T[1]]))
]);
});On iOS and Android the 15 blocks become real UIViews and Android Views through Valdi, just like in ChatGPT's iPhone app. A SwiftUI and a Compose wrapper sit on top, so it drops into an existing app. Flutter shows the same native views. The web draws them with React, and Electron reuses the web app.
A mistake should cost one part
Streaming. While the model types, the server cuts the text at the last full line, closes any open tags and tries to compile it. If that fails it backs off a few lines. Only a version that compiles goes to the app, so the screen never shows half-broken.
When the model gets it wrong. It will. Unknown parts and made-up props are dropped with a warning. A crash hides only the part that crashed. Endless loops are stopped. If nothing can be drawn, the reader still gets the text. In tool mode the problems go back to the model so it can try again.
The most common fix the compiler made was a made-up prop on <Text>.
What it can't do yet
Screens can't fetch data or run timers, and the model can only use parts from the list. Both are on purpose: the app owns the network, the look and the actions. React Native through Expo isn't done yet.
If you're building a chat app and want answers that feel like your app, not a web page, have a look. It's open source under Apache 2.0.
Prism on GitHub