|
1 | | -# A2UI (Agent to UI) Protocol |
| 1 | +# A2UI: Agent-to-User Interface |
2 | 2 |
|
3 | | -This repository contains the specification for the A2UI protocol, a JSONL-based, streaming UI protocol designed to be easily generated by Large Language Models (LLMs). |
| 3 | +A2UI is an open-source project, complete with a format |
| 4 | +optimized for representing updateable agent-generated |
| 5 | +UIs and an initial set of renderers, that allows agents |
| 6 | +to generate or populate rich user interfaces. |
4 | 7 |
|
5 | | -## Project Overview |
| 8 | +<img src="docs/assets/a2ui_composer_gallery.png" alt="Gallery of A2UI components" height="400"> |
6 | 9 |
|
7 | | -The A2UI protocol enables a server to stream a platform-agnostic, abstract UI definition to a client, which then renders it progressively using a native widget set. The core design principles are: |
| 10 | +*A gallery of UIs composed by A2UI and rendered by TODO(confirm).* |
8 | 11 |
|
9 | | -- **LLM-Friendly**: The protocol uses a simple, declarative, and flat structure that is easy for LLMs to generate. |
10 | | -- **Progressive Rendering**: The UI is streamed as a series of JSONL messages, allowing the client to render the UI as it arrives, improving perceived performance. |
11 | | -- **Platform-Agnostic**: The protocol defines an abstract component tree, and the client is responsible for mapping these abstract components to its native widget implementations. |
12 | | -- **Separation of Concerns**: The protocol separates the UI structure (components), the application state (data model), and the client-side widget rendering. |
| 12 | +## ⚠️ Status: Experimental |
13 | 13 |
|
14 | | -## Repository Layout |
| 14 | +> **Note:** A2UI is currently in **v0.8 (Public Preview)**. The specification and |
| 15 | +implementations are functional but evolving. We are opening the project to gather |
| 16 | +feedback on the format and collaborate on client renderers. Expect changes. |
15 | 17 |
|
16 | | -The repository is structured as follows: |
| 18 | +## Summary |
17 | 19 |
|
18 | | -- `docs/`: This directory contains general information about the A2UI protocol . |
19 | | -- `specification/`: Contains formal specification documents and JSON schemas for the protocol. |
| 20 | +Generative AI excels at creating text and code, but agents can struggle to |
| 21 | +present rich, interactive interfaces to users, especially when those agents |
| 22 | +are remote or running across trust boundaries. |
| 23 | + |
| 24 | +**A2UI** is an open standard and set of libraries that allows agents to |
| 25 | +"speak UI." Agents send a declarative JSON format describing the *intent* of |
| 26 | +the UI. The client application then renders this using its own native |
| 27 | +component library (Flutter, Angular, Lit, etc.). |
| 28 | + |
| 29 | +This approach ensures that agent-generated UIs are |
| 30 | +**safe like data, but expressive like code**. |
| 31 | + |
| 32 | +## High-Level Philosophy |
| 33 | + |
| 34 | +A2UI was designed to address the specific challenges of interoperable, |
| 35 | +cross-platform, generative or template-based UI responses from agents. |
| 36 | + |
| 37 | +The project's core philosophies: |
| 38 | + |
| 39 | +* **Security first**: Running arbitrary code generated by an LLM may present a |
| 40 | +security risk. A2UI is a declarative data format, not executable |
| 41 | +code. Your client application maintains a "catalog" of trusted, pre-approved |
| 42 | +UI components (e.g., Card, Button, TextField), and the agent can only request |
| 43 | +to render components from that catalog. |
| 44 | +* **LLM-friendly and incrementally updateable**: The UI is represented as a flat |
| 45 | +list of components with ID references which is easy for LLMs to generate |
| 46 | +incrementally, allowing for progressive rendering and a responsive user |
| 47 | +experience. An agent can efficiently make incremental changes to the UI based |
| 48 | +on new user requests as the conversation progresses. |
| 49 | +* **Framework-agnostic and portable**: A2UI separates the UI structure from |
| 50 | +the UI implementation. The agent sends a description of the component tree |
| 51 | +and its associated data model. Your client application is responsible for |
| 52 | +mapping these abstract descriptions to its native widgets—be it web components, |
| 53 | +Flutter widgets, React components, SwiftUI views or something else entirely. |
| 54 | +The same A2UI JSON payload from an agent can be rendered on multiple different |
| 55 | +clients built on top of different frameworks. |
| 56 | +* **Flexibility**: A2UI also features an open registry pattern that allows |
| 57 | +developers to map server-side types to custom client implementations, from |
| 58 | +native mobile widgets to React components. By registering a "Smart Wrapper," |
| 59 | +you can connect any existing UI component—including secure iframe containers |
| 60 | +for legacy content—to A2UI's data binding and event system. Crucially, this |
| 61 | +places security firmly in the developer's hands, enabling them to enforce |
| 62 | +strict sandboxing policies and "trust ladders" directly within their custom |
| 63 | +component logic rather than relying solely on the core system. |
| 64 | + |
| 65 | +## Use Cases |
| 66 | + |
| 67 | +Some of the use cases include: |
| 68 | + |
| 69 | +* **Dynamic Data Collection:** An agent generates a bespoke form (date pickers, |
| 70 | +sliders, inputs) based on the specific context of a conversation (e.g., |
| 71 | +booking a specialized reservation). |
| 72 | +* **Remote Sub-Agents:** An orchestrator agent delegates a task to a |
| 73 | +remote specialized agent (e.g., a travel booking agent) which returns a |
| 74 | +UI payload to be rendered inside the main chat window. |
| 75 | +* **Adaptive Workflows:** Enterprise agents that generate approval |
| 76 | +dashboards or data visualizations on the fly based on the user's query. |
| 77 | + |
| 78 | +## Architecture |
| 79 | + |
| 80 | +The A2UI flow disconnects the generation of UI from the execution of UI: |
| 81 | + |
| 82 | +1. **Generation:** An Agent (using Gemini or another LLM) generates or uses |
| 83 | +a pre-generated `A2UI Response`, a JSON payload describing the composition |
| 84 | +of UI components and their properties. |
| 85 | +2. **Transport:** This message is sent to the client application |
| 86 | +(via A2A, AG UI, etc.). |
| 87 | +3. **Resolution:** The Client's **A2UI Renderer** parses the JSON. |
| 88 | +4. **Rendering:** The Renderer maps the abstract components |
| 89 | +(e.g., `type: 'text-field'`) to the concrete implementation in the client's codebase. |
| 90 | + |
| 91 | + |
| 92 | +## Dependencies |
| 93 | + |
| 94 | +A2UI is designed to be a lightweight format, but it fits into a larger ecosystem: |
| 95 | + |
| 96 | +* **Transports:** Compatible with **A2A Protocol** and **AG UI**. |
| 97 | +* **LLMs:** Can be generated by any model capable of generating JSON output. |
| 98 | +* **Host Frameworks:** Requires a host application built in a supported framework |
| 99 | +(currently: Web or Flutter). |
| 100 | + |
| 101 | +## Getting Started |
| 102 | + |
| 103 | +The best way to understand A2UI is to run the samples. |
| 104 | + |
| 105 | +### Prerequisites |
| 106 | +* Node.js (for web clients) |
| 107 | +* Python (for agent samples) |
| 108 | +* A valid [Gemini API Key](https://aistudio.google.com/) is required for the samples. |
| 109 | + |
| 110 | +### Running the Restaurant Finder Demo |
| 111 | + |
| 112 | +1. **Clone the repository:** |
| 113 | + ```bash |
| 114 | + git clone https://github.com/google/A2UI.git |
| 115 | + cd A2UI |
| 116 | + ``` |
| 117 | + |
| 118 | +2. **Set your API Key:** |
| 119 | + ```bash |
| 120 | + export GEMINI_API_KEY="your_gemini_api_key" |
| 121 | + ``` |
| 122 | + |
| 123 | +3. **Run the Agent (Backend):** |
| 124 | + ```bash |
| 125 | + cd samples/agent/adk/restaurant_finder |
| 126 | + uv run . |
| 127 | + ``` |
| 128 | + |
| 129 | +4. **Run the Client (Frontend):** |
| 130 | + Open a new terminal window: |
| 131 | + ```bash |
| 132 | + cd samples/client/lit/shell |
| 133 | + npm install |
| 134 | + npm run dev |
| 135 | + ``` |
| 136 | + |
| 137 | +For Flutter developers, check out the [GenUI SDK](https://github.com/flutter/genui), |
| 138 | +which uses A2UI under the hood. |
| 139 | + |
| 140 | +CopilotKit has a public [A2UI Widget Builder](https://go.copilotkit.ai/A2UI-widget-builder) |
| 141 | +to try out as well. |
| 142 | + |
| 143 | + |
| 144 | +## Roadmap |
| 145 | + |
| 146 | +We hope to work with the community on the following: |
| 147 | + |
| 148 | +* **Spec Stabilization:** Moving towards a v1.0 specification. |
| 149 | +* **More Renderers:** Adding official support for React, Jetpack Compose, iOS (SwiftUI), and more. |
| 150 | +* **Additional Transports:** Support for REST and more. |
| 151 | +* **Additional Agent Frameworks:** Genkit, LangGraph, and more. |
| 152 | + |
| 153 | +## Contribute |
| 154 | + |
| 155 | +A2UI is an **Apache 2.0** licensed project. We believe the future of UI is agentic, |
| 156 | +and we want to work with you to help build it. |
| 157 | + |
| 158 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to get started. |
0 commit comments