# Open Generative UI

> CopilotKit's open-source showcase for agents that stream live, sandboxed HTML/SVG UIs into chat

- Category: App UIs & Builders / Generative UI SDKs
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/CopilotKit/OpenIntelligentUI
- Website: https://opengenerativeui.copilotkit.ai/
- Canonical page: https://ai-tldr.dev/tools/copilotkit-open-generative-ui/

## In short

Open Generative UI is CopilotKit's open-source showcase for agents that stream live, sandboxed HTML/SVG UIs into chat. It sits in the Generative UI SDKs category of the App UIs & Builders tools and is open-source, written in TypeScript and licensed MIT. To get started: clone and install.

## Overview

Open Generative UI is an open-source showcase and template from the CopilotKit team for building AI-generated, interactive UI. Instead of answering only in text, the agent can visualize an algorithm, build a 3D animation, draw a chart or produce an interactive diagram, and each result is rendered as live HTML/SVG inside a sandboxed iframe with automatic light/dark theming, progressive reveal animations and responsive sizing.

The repo is a Turborepo monorepo with three apps: a Next.js 16 frontend built on CopilotKit v2, React 19 and Tailwind 4; a Python agent built with LangChain Deep Agents (`create_deep_agent`) plus CopilotKit middleware; and a standalone Model Context Protocol server. Rather than stuffing every visualization instruction into the system prompt, the agent loads `SKILL.md` files from `apps/agent/skills/` on demand — an advanced-visualization skill, a master playbook and an SVG-diagrams skill.

Under the hood, the CopilotKit runtime exposes a `generateSandboxedUi` tool when `openGenerativeUI` is enabled. Its parameters stream in order (`initialHeight`, `placeholderMessages`, `css`, `html`, `jsFunctions`, `jsExpressions`), `OpenGenerativeUIMiddleware` turns the tool call into activity events, and the frontend morphs each update into a preview iframe with Idiomorph before booting the final sandbox. The generated UI can call back into the host through Zod-validated `sendPrompt` and `openLink` functions. The agent runs on Anthropic Claude by default; the README warns that smaller or weaker models produce broken layouts or incomplete visualizations.

## What it does

- Agent-generated visuals: algorithm walkthroughs, WebGL/CSS3D scenes, charts, network diagrams, forms, simulations and math plots
- Streaming render path: HTML streams into a flicker-free preview iframe, then boots a sandbox with the shared design-system CSS and a CDN importmap
- Skills-based Deep Agent that loads SKILL.md instructions on demand instead of one giant system prompt, with built-in planning and sub-agent support
- Two-way sandbox bridge (Zod-validated `sendPrompt` / `openLink`) plus a ResizeObserver that auto-sizes each iframe to its content
- Standalone MCP server with an `assemble_document` tool, skill resources and prompt templates for Claude Desktop, Claude Code, Cursor and other MCP clients
- Reference examples of other CopilotKit patterns: `useComponent` charts, `useFrontendTool`, `useHumanInTheLoop` and `useDefaultRenderTool`

## Getting started

The project's docs list Node.js 22+, Python 3.12+, pnpm 9+ and uv as prerequisites. The agent needs an Anthropic API key; setting `LLM_MODEL` to a `gpt-*` name routes to OpenAI instead (with `OPENAI_API_KEY`).

1. Clone and install

   `make setup` runs `pnpm install` and creates `apps/agent/.env` if it does not exist.

```bash
git clone https://github.com/CopilotKit/OpenIntelligentUI.git
cd OpenIntelligentUI
make setup
```

2. Add your API key

   Put your Anthropic key in `apps/agent/.env`. Optional variables in the root `.env` include `LLM_MODEL`, rate-limit settings and `MCP_SERVER_URL`.

```bash
ANTHROPIC_API_KEY=sk-ant-...
```

3. Start everything

   `make dev` starts the Next.js app at http://localhost:3000 and the agent at http://localhost:8123. Use `make dev-app`, `make dev-agent` or `make dev-mcp` to run one service at a time.

```bash
make dev
```

4. Try a prompt

   Open http://localhost:3000, type something like "Create a todo list for a weekend project" or click one of the demo suggestions, and the agent answers with generative UI rendered in the chat.

5. Optional: use the MCP server from Claude Code

   Start the HTTP server, then point your client at it in `.mcp.json`. Claude Desktop can use the stdio build (`node dist/stdio.js`) instead.

```bash
cd apps/mcp && pnpm dev

# .mcp.json
{
  "openGenerativeUI": {
    "url": "http://localhost:3100/mcp"
  }
}
```

## When to use it

- Studying a working reference for streaming agent-written HTML/SVG into a sandboxed iframe before adding generative UI to your own CopilotKit app
- Building explainer or tutoring assistants that answer with interactive diagrams, charts and simulations instead of paragraphs
- Giving Claude Desktop, Claude Code or Cursor a shared design system and visualization skills through the bundled MCP server
- Starting a Next.js + LangChain Deep Agents project from a template that already wires up CopilotKit, skills and human-in-the-loop
