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.

  • 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)
// React
import { AgentInterface, agUIAdapter, fetchLLM } from "@openuidev/react-ui";
import { openuiLibrary } from "@openuidev/react-ui/genui-lib";

const llm = fetchLLM({ url: "/api/chat", streamAdapter: agUIAdapter() });
<AgentInterface llm={llm} componentLibrary={openuiLibrary} />;

A full working app is in examples/fastapi-react.

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.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 genui-py 0.1.0
File Size Uploaded Provenance Actions
genui_py-0.1.0.tar.gz 70.1 kB Without provenance Details for genui_py-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 154.1 kB

Release files / genui_py-0.1.0.tar.gz

Download URL genui_py-0.1.0.tar.gz
Size 70.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ad718fe4d9b77f3ce13e3ae0757c2cc5897a440de85823ff4863c974dd01dbd
BLAKE2b-256 checksum
How to use checksums
c24343d3c6fce1df43e75a38bc47fe414893ad301551d70ca27f26abc23da55a
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.0-py3-none-any.whl

Download URL genui_py-0.1.0-py3-none-any.whl
Size 84.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcf40f4edadc783357373e377ed9adfb634bdf55a652292d15b12eab0f52b18b
BLAKE2b-256 checksum
How to use checksums
f72dd978db07a8e0f4547681ae4c56d3b8e664a620b1f42482adc01e3abebe29
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.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.

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