Skip to main content

genui

PyPI Python License Telemetry

Generative UI for Python agents. Your Python backend streams OpenUI Lang; your React app renders it as live cards, tables, forms and charts with OpenUI's open-source renderer.

Live demo & playground · Gallery · PyPI · npm

A UI streaming in token by token

See it in action: Wander

examples/wander is a full booking concierge built with genui: a Python agent on Gemini with real tools (search, availability, booking) and a React app with custom components (polaroid stay cards, a range calendar, a receipt, a boarding-pass ticket). The agent answers only in OpenUI Lang; genui handles the prompt, the tool events, the streaming and the button clicks.

Wander home Wander booking flow

  • Free, MIT. pip install genui-py. No account, no API key, no paid tier.
  • Your data stays with you. Prompt generation, validation and streaming run in your process. Zero telemetry, zero network calls.
  • Any model. OpenAI, Anthropic, Gemini, or local models through any OpenAI-compatible server (Ollama, vLLM, LM Studio).
  • Any agent. Plain Python, LangGraph, OpenAI Agents SDK, Pydantic AI, CrewAI — if it yields text, genui can stream it.
  • Spec-exact. Implements the OpenUI 1.0 spec and runs the official conformance fixtures in CI.

genui is a community project. It is not affiliated with or endorsed by Thesys, the authors of OpenUI.

How it fits

React (OpenUI renderer)                Python (your agent + genui)
───────────────────────                ───────────────────────────
components (Zod + React)  ──spec.json──▶  Library.from_spec()
                                           library.system_prompt()  → your LLM
<AgentInterface agUIAdapter()> ◀──SSE──  stream_response(llm_stream)
button click @ToAssistant  ──POST────▶  read_run(): clean history for the model

The frontend owns the components. npx @openuidev/cli generate src/library.ts --spec --out spec.json exports them, and genui reads that file, so the prompt and the renderer can never drift apart.

Quick start (FastAPI)

pip install "genui-py[fastapi,openai]"
from fastapi import FastAPI, Request
from openai import AsyncOpenAI
from genui import Library
from genui.integrations.fastapi import read_run, stream_response

library = Library.from_spec("spec.json")
SYSTEM_PROMPT = library.system_prompt()
client = AsyncOpenAI()
app = FastAPI()

@app.post("/api/chat")
async def chat(request: Request):
    run = await read_run(request)
    stream = await client.chat.completions.create(
        model="gpt-5.5-mini",
        messages=[{"role": "system", "content": SYSTEM_PROMPT}, *run.messages],
        stream=True,
    )
    return stream_response(stream, run=run)
npm install genui-react
// React
import { GenUIChat } from "genui-react";
import "genui-react/styles.css";

<GenUIChat url="/api/chat" />;

Prefer composing OpenUI's components yourself? genuiLLM({ url }) returns the client for AgentInterface, and GenUIRenderer renders a single stored response.

A full working app is in examples/fastapi-react. Backend examples for Anthropic, Ollama (fully local), LangGraph, OpenAI Agents SDK, Pydantic AI and Flask are in examples/backends.

What you can stream

stream_response() (and genui.stream.encode() for other frameworks) accepts sync or async iterables of:

item example
str yield 'root = Card([title])' from any agent
OpenAI Chat Completions chunks await client.chat.completions.create(..., stream=True)
OpenAI Responses events client.responses.create(..., stream=True)
Anthropic Messages events client.messages.create(..., stream=True)
LangChain / LangGraph message chunks graph.astream(..., stream_mode="messages")
genui events ToolCallStart, ToolCallArgs, ToolResult, StreamError, …

Output formats: "ag-ui" (default, for agUIAdapter()) or "openai" (for openAIAdapter()). Exceptions inside your agent become a RUN_ERROR the UI can show.

Validate model output

from genui.lang import parse

result = parse(text, library.to_spec())
result.errors      # structured errors with hints you can feed back to the model

Message protocol

genui.messages reads and writes OpenUI's stored-message format (]]>openui:content marker lines), turns button clicks into model-ready turns, and strips markers before anything reaches the model.

Status

Alpha. API may change before 1.0. Roadmap: framework adapters (LangGraph, OpenAI Agents SDK, Pydantic AI), local auto-fix loop, Markdown → UI "beautify" mode.

Brand

Logo files are in assets/: logo.svg (icon), logo-wordmark-{light,dark}.svg, PNG sizes, and social-preview.png (1280×640) for the GitHub repo card.

License

MIT. The OpenUI spec and fixtures in spec/ are © Thesys, MIT — see spec/NOTICE.md.

Metadata

Release files for genui-py 0.1.1

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

Source distribution (sdist)

Source distribution for genui-py 0.1.1
File Size Uploaded Provenance Actions
genui_py-0.1.1.tar.gz 71.9 kB Without provenance Details for genui_py-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for genui-py 0.1.1
File Interpreter ABI Platform Actions
genui_py-0.1.1-py3-none-any.whl Python 3 none any Details for genui_py-0.1.1-py3-none-any.whl

Total release size: 157.8 kB

Release files / genui_py-0.1.1.tar.gz

Download URL genui_py-0.1.1.tar.gz
Size 71.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c51ca21feb2d528aaf6f41d142d1de581ca1a326fdd6278afae622b3bb04a13f
BLAKE2b-256 checksum
How to use checksums
3017dd550e08f268002e3040dfeb761abe41be0ada81ac6e78024cfc12df7dec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / genui_py-0.1.1-py3-none-any.whl

Download URL genui_py-0.1.1-py3-none-any.whl
Size 85.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f29481fc7f1a02bd39ad3ec78960cf26954cebc494c33170e510ac4571a73bf
BLAKE2b-256 checksum
How to use checksums
8e90d8fb958e4a919a4f761c542f6e9879d4382baa97c27a04da292c68822203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for genui-py 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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