Skip to main content

DyUI is the Python framework for professional chatbots that answer in interfaces. Write one Python file, run dyui run app.py, and get a calm, beautifully animated chat app — frontend and backend — where your LLM replies with tables, charts, cards, forms and buttons, not just text.

import dyui

app = dyui.App(title="Travel Bot", starters=["Plan a weekend in Lisbon"])

@app.on_message
async def reply(msg: dyui.Message, chat: dyui.Chat):
    async for part in dyui.llm.stream("openai/gpt-5", chat.history,
                                      system="You are a calm, expert travel agent.",
                                      components=app.catalog):   # ← the LLM can now render UI
        yield part
pip install "dyui[openai]"
dyui run app.py          # → http://127.0.0.1:8000

No API key yet? pip install dyui && dyui demo opens a guided tour that needs none.

A DyUI chatbot answering with stats, a chart, a table and a callout

The real app, from dyui demo — every card was streamed by the (simulated) LLM.

Why DyUI

The LLM renders UI. DyUI teaches your model a component catalog through an auto-generated system prompt, parses its output while it streams, validates it, and renders it — inline, between sentences.

Professional out of the box. Conversation history, streaming with stop, regenerate and edit, file uploads, feedback, light and dark themes, mobile layout, password gate — calm motion at every interaction.

Any model. Any framework. OpenAI, Anthropic, Ollama, Groq, OpenRouter, Gemini, Mistral, DeepSeek, xAI, LangGraph — or your own SDK. DyUI parses raw text, so anything that streams works.

Your own components, in pure Python. Define a pydantic model with a render(); the LLM learns it automatically. The system prompt grows with your app.

Interfaces that talk back. Buttons, forms, choices and approvals route to Python handlers — or straight back to the LLM. await chat.ask(...) pauses an agent for human approval.

Safe by design. The model only ever sends data. No model HTML, sanitized links, verified actions, sandboxed developer templates.

Quickstart

pip install dyui
dyui new my-bot --template openai     # or: basic · anthropic · langgraph
cd my-bot && dyui run

dyui run serves the app and reloads it whenever you save. app is a standard ASGI app, so uvicorn app:app works in production too.

How the LLM writes UI

DyUI adds a short, generated section to your system prompt that lists the components your bot may use. The model writes ordinary Markdown, and puts components in fenced dyui blocks — one JSON object per line:

Here are two options for this weekend.
```dyui
{"ui":"flight","airline":"TAP","depart":"Fri 18:05","price":189}
{"ui":"quick_replies","options":["Check hotels too","Book the cheaper one"]}
```
Want me to hold a seat?

The server parses that stream incrementally. A component appears as a soft skeleton the moment its type is known, fills in as its props arrive, and blooms into place when the line completes. Invalid output degrades to a quiet "couldn't display" chip — the prose is never lost.

flowchart LR
    H["Your handler<br/>(any LLM · any SDK)"] -- "text stream" --> P["DyUI fence parser<br/>+ validation"]
    H -- "ui.Table(...) · chat.step(...)" --> S
    P --> S["SSE stream"]
    S --> W["DyUI web app<br/>(36 animated components)"]
    W -- "clicks · forms · approvals" --> A["@app.on_action<br/>or back to the LLM"]
    A --> H

Your component library — the prompt grows with your app

from dyui import ui

@app.component
class Flight(dyui.Component):
    """A bookable flight option. Use when listing specific flights."""
    airline: str
    depart: str
    price: float

    def render(self):
        return ui.Card(self.airline, ui.Stat("Price", f"${self.price:.0f}"),
                       actions=[ui.Button("Book", action="book_flight", data=self.model_dump())])

@app.on_action("book_flight")
async def book(action: dyui.Action, chat: dyui.Chat):
    confirm = await chat.ask(ui.Confirm("Book this flight?", text=action.data["airline"]))
    if confirm.values.get("confirmed"):
        yield ui.Callout("Booked — your confirmation is on its way.", level="success")

Register a component and the next turn's system prompt includes it. Change a field or the docstring and the prompt changes with it. Choose what each bot — or each turn — may use:

dyui.App(components=["table", "chart", "stat", "buttons"])   # a subset of built-ins
app.catalog.only("flight", "confirm", "quick_replies")        # per turn, e.g. at checkout

dyui catalog app.py prints the exact prompt DyUI will send, with a token estimate.

36 components, ready to render

group components
Content markdown · callout · code · quote · sources · badges · divider
Data table · stat · stats · keyvalue · chart (bar · line · area · pie · donut · scatter) · progress · timeline · json
Media image · gallery · video · audio · file · link_preview
Interactive buttons · quick_replies · choice · form · confirm · rating
Layout card · grid · tabs · accordion · carousel · list
Agent step · reasoning · plan

Every component blooms in, streams gracefully while the model is still writing it, works in light and dark, respects reduced-motion, and is keyboard accessible. Browse them all with live demos →

Works with

Built-in streaming openai/… · anthropic/… · ollama/… · groq/… · openrouter/… · gemini/… · mistral/… · deepseek/… · together/… · xai/…
Agent frameworks LangGraph (dyui.integrations.langgraph) — emit components from any node
Anything else Yield raw text from any SDK and add app.catalog.prompt() to your system prompt

Steps, reasoning and human-in-the-loop

@app.on_message
async def reply(msg, chat):
    async with chat.step("Searching flights", type="search") as step:
        step.output = await search_flights(msg.text)          # live status + duration
    yield ui.Table(columns=["Airline", "Depart", "Price"], rows=to_rows(step.output))

Reasoning models stream their thinking into a collapsible block automatically.

CLI

command
dyui run [app.py] Serve your app with hot reload (--host, --port, --open)
dyui new <dir> Scaffold a project (basic, openai, anthropic, langgraph)
dyui demo A guided tour — no API key needed
dyui catalog [app.py] Print the generated UI prompt and its token cost
dyui claude init Hand your app to Claude Code to design custom components (gemini / codex too)

Deploy

uvicorn app:app --host 0.0.0.0 --port 8000

DyUI stores conversations in SQLite (./.dyui/dyui.db) by default. Pass persist=False for memory-only, or plug in your own Store. See Deploy for Docker, reverse proxies and hosting guides.

Roadmap

  • Auto-repair loop for invalid components, and streamed tool-call arguments in ui_mode="tools"
  • dyui-react — the same components for your own React / Next.js app (npm)
  • Conversation branching, voice, and a side panel for long artifacts
  • Auth providers (OAuth) and multi-user workspaces

Repository

path
python/ the dyui package (framework, server, CLI)
web/ the chat app and component library (React, bundled into the wheel)
docs/ the documentation site (Astro Starlight)
examples/ runnable example bots
SPEC.md the engineering spec: protocol, component catalog, brand
SECURITY.md security policy, threat model, and how to report a vulnerability

Contributions are welcome — start with SPEC.md, then cd web && npm install && npm run build:py and pip install -e "python[all,dev]".

Security

DyUI treats model output as untrusted: components are validated against their schemas, URLs are sanitised, raw HTML from the model is never rendered, and the app ships with a strict CSP and CSRF protection. See SECURITY.md — please report vulnerabilities privately via GitHub security advisories.

License

MIT © DyUI contributors

Metadata

Release files for dyui 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dyui 1.0.0
File Size Uploaded Provenance Actions
dyui-1.0.0.tar.gz 672.6 kB With provenance Details for dyui-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dyui 1.0.0
File Interpreter ABI Platform Actions
dyui-1.0.0-py3-none-any.whl Python 3 none any Details for dyui-1.0.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / dyui-1.0.0.tar.gz

Download URL dyui-1.0.0.tar.gz
Size 672.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c18388b405afafcbdbe3598ea4f5cdbc3041c6507346bde84c837c08f30a032b
BLAKE2b-256 checksum
How to use checksums
e9b299bd50e23852cdfcd255a3d1d62b3b8aef6b7f9c64fcb88e97ca1cb63fa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / dyui-1.0.0-py3-none-any.whl

Download URL dyui-1.0.0-py3-none-any.whl
Size 701.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5d2af776adc003d717af0148a3c98e2b49670f2bc537e962fb68fc19e5c7716
BLAKE2b-256 checksum
How to use checksums
b9c9bbbad03b4bb1f7680ad945b07f28537f5ef4d4f461e500e87ae8514f1225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for dyui 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dyui-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page