Abhishek Bansal
Prism • Open source SDK • Nov 2026 • 8 min read

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.

Runs oniOS · Android · Flutter · Web · Electron
A tip calculator inside a chat, drawn by Prism on iPhone.
01The field

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 codeNamed partsCode, drawn natively
WhoMCP Apps, Claude artifacts, GeminiGoogle A2UI, Vercel json-renderChatGPT's own answers, Prism
Model sendsHTML / JSJSONSmall JSX program
Drawn byiframe / web viewThe appThe app
Logic on screenYesLittleYes
Feels likeA web pageThe appThe app

Most people only know the first. ChatGPT's own answers use the third.

02The discovery

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.

~158 MBWeb view for a third-party widget
NoneWeb engine for ChatGPT's own answers

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.

WhereDrawn with
iPhoneNative views, using Snap's Valdi
chatgpt.comReact, straight into the page
Mac appThe same React code, since the new Mac app is Electron
Third-party widgetsA web view
03How it works

The model writes a program, not a page

Four steps take a reply from the model to your screen:

Modelwrites JSX + state→Servercompiles, checks, adds backup→Hidden sandboxruns the code→Appdraws native views

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:

What the model wrote
{@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>
What the server sent (trimmed)
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 constants list. 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.

04Why it matters

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.

05Prism

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:

ChatGPT (DIL)
{@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>
Prism
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 counter, after two taps.
Steps, a quiz, a plan picker and cards from the part library.
06The big difference

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
LooksThe model picks coloursMeaning only. The app's design decides.
Hooks13, including useEffect and useNowOnly useState
SyntaxJSX mixed with Svelte-style {#each}Plain JSX and .map
PartsAbout 45, all drawn by the app39 parts that expand into 15 basic blocks. New parts can ship from the server.
Real actionsOpen a link, copy, send a message and a few moreThe same, plus actions behind a <Confirm> tap
ModelsOpenAI'sAny: 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.ask sends a message as the user. P.open, P.copy and P.toast do what they say.
  • Only parts from the list. Card, Stat, Quiz, Choice, Carousel, Steps, Chart, Confirm and the rest.
07Under the hood

From text to native views

  1. Compile on the server. Babel reads the block, turns each useState into a state box, checks every part and prop against the catalog, and turns tags into plain calls.
  2. Ship an envelope. JSON with the compiled code, the starting state, the words, the parts it uses and a Markdown backup.
  3. Run it in a sandbox. One small runtime file runs on every platform. It only takes and returns text: load(id, envelope) and event(id, handler, value), which give back the new tree.
  4. 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.

Comparing laptops, on iOS.
Booking a table, on Android.
08Holding up

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 answer streams in, then the screen lands.
Two broken parts. Only they disappear.
0 / 200Answers that crashed, with Claude Haiku
30 / 30Clean answers with the latest prompt, in two runs

The most common fix the compiler made was a made-up prop on <Text>.

09What's next

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