Claude Dashboards lets you ask Claude a question about your data and get an AI dashboard in return. Claude generates the dashboard once, and every time someone opens it, it loads fresh data without making another model call. We took it apart earlier this month. In this post, we'll look at what it takes to build something similar into your own app.
Getting an LLM to generate a dashboard is surprisingly easy. Getting it to work reliably in production is a different story. You need to make sure that:
- Every AI dashboard actually works.
- The numbers it shows are accurate.
- Users can edit a dashboard without breaking what's already there.
- Dashboards can be shared without compromising data, security, or access permissions.
- None of this costs a fortune in tokens.
We'll go through each of these challenges, why they arise, and how we solve them in the OpenUI Dashboards API.
We've also built OpenDashboards on top of this API to show what a complete product can look like. Think Metabase, but instead of manually building dashboards, you connect your database or analytics tool, describe what you want in plain English, and refine it through conversation.
AI dashboards rest on a declarative program, not generated code
The OpenUI Dashboards API generates dashboards in OpenUI Lang. Instead of writing HTML or JavaScript, the model writes a short program that names components from your library. A Query in that program names one of your data tools, so the renderer loads fresh data every time the dashboard opens. OpenUI Lang has worked this way since v0.5 in April.
This matters for everything that follows. The program only describes the dashboard; it doesn't run anything. That's what makes it possible to check a dashboard before anyone sees it, edit just part of it, and share it safely.
A model will sometimes write a dashboard that doesn't work
Whatever format the model writes, whether that's HTML, JSON or OpenUI Lang, even a good model will sometimes get the markup wrong, the queries wrong, or both. When that happens, whoever opens the dashboard gets an error or an empty page. Cheaper models get it wrong more often.
In a demo, you can retry until it works. In your app, you can't hand a user a broken dashboard and ask them to try again.
In the OpenUI Dashboards API, we catch invalid OpenUI Lang and invalid queries before a dashboard is saved and fix them, so your users only ever get a dashboard that works.
On our hardest set of requests (funnels, retention cohorts, web vitals, revenue against a target), about 1 in 7 of Claude Haiku 5.5's dashboards broke on its own. With these checks, none did.
A dashboard that works can still show the wrong numbers
A dashboard can load without errors and still show the wrong thing: a chart that reads a column that doesn't exist, or a total over the wrong rows. That's worse than a broken dashboard, because nothing tells your user something's off, and they act on the numbers.
This is where we put most of our effort, and it's how the OpenUI Dashboards API works:
- A prompt tuned for dashboards. We generate it from your component library, with rules for what makes a good dashboard: how to lay out a page, when to add filters and previous periods, and how to label numbers.
- Checks before and after the model writes. Before writing, the model looks at your data by calling your tools, so its charts are bound to fields that actually exist. After, we check that every query and script it wrote matches the shape of what your tools return. A chart reading
rows.revenuewhen the rows haveamountis caught before anyone sees it. - A replay before saving. We run the finished dashboard and its scripts again on the server with your real data. Anything that comes out empty or broken goes back to the model to fix, so you never have to tell it "this chart is empty, fix it."
With these checks, Claude Haiku 5.5 scored 110 out of 120 in a blind review on our hardest requests, against 94 on its own.
People never build a dashboard just once
Your users won't build a dashboard once and be done with it. They'll refine it, share it, and keep it open on a second screen.
Edits that keep what's there. When someone asks to "add a pie chart by payment method", they expect a pie chart added, not the whole dashboard rebuilt and the filters they tuned lost. If the model rewrites the full dashboard on every edit, whatever format it writes, that's exactly what can happen.
In the OpenUI Dashboards API, editing a dashboard uses OpenUI Lang's incremental editing: the model writes only the parts that change, and we merge them into the dashboard. Every edit goes through the same checks as a new build, everyone stays on the current version until the new one is ready, and two people editing at once can't overwrite each other.
An edit in OpenDashboards, at 8× speed: the dashboard stays up while the new KPI is built, then it slots in.
Live updates for everyone watching. While a dashboard is being built, everyone looking at it sees it appear at once and fill in as it's written. They see only the dashboard, never the model's commentary or script code.
Sharing turns every dashboard into a security boundary
Sharing is what makes a dashboard useful. It also means a dashboard that one person asked a model to write opens in someone else's browser, with someone else's access. That can go wrong in three ways, and you need to handle each one.
Data leaks
If a shared dashboard carries the results its builder saw, or runs its queries as the builder, whoever opens it sees data that isn't theirs.
In the OpenUI Dashboards API, sharing a dashboard with a person or a team shares its layout and queries, never its results. Your data tools always run on your own servers, with the auth context of whoever is viewing the dashboard. So two people can open the same dashboard and each see only their own numbers.
Code execution
If a dashboard can run code in the browser, anyone who can build a dashboard can put a harmful script in one and send you the link. Just opening it could steal your cookies or farm crypto in your browser. In a multi-tenant app, that's a compliance nightmare.
Generating HTML or JavaScript is the default approach for a reason: it's flexible. But that flexibility is exactly the problem once dashboards can be shared.
OpenUI Lang has no HTML or JavaScript in it. The model names components from your library, and data comes in through Query, which calls one of your tools and puts its result straight into those components. There's no code between your data and the screen, so a shared dashboard has nothing to run in the viewer's browser.
Some numbers still need real logic, like grouping customers by age or combining two tools into one metric. For those, the model writes a small JavaScript script. In the OpenUI Dashboards API, scripts only ever run on the server, in a sandbox that:
- starts fresh and empty every time: no network, no filesystem, thrown away after each run, with hard limits on time and memory so a runaway script stops;
- can call your other tools safely: only the tools you registered, each call running on your server with the viewer's own access, so a script can combine data without reaching anything it shouldn't;
- keeps code on the server: browsers get the dashboard, never the script, and nobody can swap in code of their own.
Because the rest of the dashboard can't run code, this sandbox can stay light. Each script runs in a fresh QuickJS virtual machine compiled to WebAssembly, so there's no full-blown sandbox, such as a container for every run, to operate.
Access control
"Shared" isn't one permission. Someone with view access should be able to open a dashboard, and someone with edit access should be able to change it. If you don't model these explicitly, or you skip a check somewhere, someone can end up editing or resharing a dashboard they should only be able to see.
The OpenUI Dashboards API checks access on every request, so removing a share takes effect on the next one, and someone without access can't tell the dashboard exists.
The browser needs care too. It has to load a user's dashboards without ever holding your API key. With the API, your server mints a short-lived token for each user, signed so it can't be altered to claim someone else, and refreshed before it expires.
In your app, every token is on your bill
Inside Claude, token cost is Anthropic's concern, not yours. When you ship dashboards in your own app, you pay for every build and every edit, so it's worth designing for cost from the start.
A few things keep that bill down:
- Opening a dashboard costs nothing. There's no model call when someone opens it; the renderer runs your queries for fresh data. You pay for a dashboard when it's built, not every time it's viewed.
- Edits cost less than rebuilds. With incremental editing, the model writes only the parts that change, not the whole dashboard again.
- You can use a smaller model. We built the API to work with any size of model, so you can choose by cost. The checks above are what make cheaper models work: DeepSeek v4.1 Flash built every test dashboard correctly at a third of a cent per build.
Here's what that looks like in practice. We gave Claude Dashboards and the OpenUI Dashboards API the same request (eight weeks of signups: last week's number, the change on the week before, and a bar chart per week) on the same model, Claude Sonnet 5.5 at medium effort, three times each:
| Time to a finished dashboard (median of 3) | Output tokens per build | |
|---|---|---|
| Claude Dashboards on claude.ai | 84 s | about 3,900 |
| OpenUI Dashboards API | 5 s | about 420 |
Both got the numbers right every time. The difference is what the model has to write: for each dashboard, Claude writes a full HTML page with its own JavaScript and d3 code, while the API's model writes a few lines of OpenUI Lang that name components you already have. Fewer tokens out means a faster build and a smaller bill.
Claude's tokens are what it wrote for the dashboard and its reply, counted with Anthropic's token counter; its thinking isn't visible on claude.ai, so its real count is higher. The API's count is exact, from its usage data.
Building this into your app
In the OpenUI Dashboards API, we've taken care of all of this, so you don't have to. All it needs from you is your component library, a model and your data tools:
import { OpenUIClient } from "@openuidev/server";
import spec from "../generated/spec.json"; // generated from your component library by the OpenUI CLI
import { dataTools } from "./data"; // functions on your server that return data
export const dashboards = new OpenUIClient().defineDashboard({
library: spec,
model: "anthropic/claude-sonnet-5.5",
tools: dataTools,
});To get started, ask your coding agent:
Install the OpenUI skill with `npx skills add thesysdev/skills`. Ask me whether to build a new app with live dashboards (scaffold it with `npx @openuidev/cli@latest create --example assistant-ui-dashboards`) or add them to my existing one, then follow the skill's dashboards guide to complete it.To see it in a complete product, try OpenDashboards or read its source on GitHub.
The Dashboards API is part of OpenUI Cloud, which has a free tier.