Quickstart: Run A2UI in 5 Minutes
Quickstart: Run A2UI in 5 Minutes
Section titled “Quickstart: Run A2UI in 5 Minutes”Get hands-on with A2UI by running the restaurant finder demo. This guide will have you experiencing agent-generated UI in less than 5 minutes.
What You’ll Build
Section titled “What You’ll Build”By the end of this quickstart, you’ll have:
- ✅ A running web app with A2UI Lit renderer
- ✅ A Gemini-powered agent that generates dynamic UIs
- ✅ An interactive restaurant finder with form generation, time selection, and confirmation flows
- ✅ Understanding of how A2UI messages flow from agent to UI
Prerequisites
Section titled “Prerequisites”Before you begin, make sure you have:
- Node.js (v18 or later) — Download here
- uv (Python package manager) — Install here (used to run the Python agent backend)
- A Gemini API key — Get one free from Google AI Studio
⚠️ Security Notice
This demo runs an A2A agent that uses Gemini to generate A2UI responses. The agent has access to your API key and will make requests to Google’s Gemini API. Always review agent code before running it in production environments.
Step 1: Clone the Repository
Section titled “Step 1: Clone the Repository”git clone https://github.com/google/a2ui.gitcd a2uiStep 2: Set Your API Key
Section titled “Step 2: Set Your API Key”Export your Gemini API key as an environment variable:
export GEMINI_API_KEY="your_gemini_api_key_here"Step 3: Navigate to the Lit Client
Section titled “Step 3: Navigate to the Lit Client”cd samples/client/litStep 4: Install and Run
Section titled “Step 4: Install and Run”Run the one-command demo launcher:
npm installnpm run demo:allThis command will:
- Install all dependencies
- Build the A2UI renderer
- Start the A2A restaurant finder agent (Python backend)
- Launch the development server
- Open your browser to
http://localhost:5173
✅ Demo Running
If everything worked, you should see the web app in your browser. The agent is now ready to generate UI!
Step 5: Try It Out
Section titled “Step 5: Try It Out”In the web app, try these prompts:
- “Book a table for 2” - Watch the agent generate a reservation form
- “Find Italian restaurants near me” - See dynamic search results
- “What are your hours?” - Experience different UI layouts for different intents
What’s Happening Behind the Scenes
Section titled “What’s Happening Behind the Scenes”┌─────────────┐ ┌──────────────┐ ┌────────────────┐│ You Type │────────>│ A2A Agent │────────>│ Gemini API ││ a Message │ │ (Python) │ │ (LLM) │└─────────────┘ └──────────────┘ └────────────────┘ │ │ │ Generates A2UI JSON │ │<────────────────────────┘ │ │ Streams JSONL messages v ┌──────────────┐ │ Web App │ │ (A2UI Lit │ │ Renderer) │ └──────────────┘ │ │ Renders native components v ┌──────────────┐ │ Your UI │ └──────────────┘- You send a message via the web UI
- The A2A agent receives it and sends the conversation to Gemini
- Gemini generates A2UI JSON messages describing the UI
- The A2A agent streams these messages back to the web app
- The A2UI renderer converts them into native web components
- You see the UI rendered in your browser
Anatomy of an A2UI Message
Section titled “Anatomy of an A2UI Message”Let’s peek at what the agent is sending. Here’s a simplified example of the JSON messages:
=== “v0.8 (Stable)”
**Defining the UI:**
```json{"surfaceUpdate": {"surfaceId": "main", "components": [ {"id": "header", "component": {"Text": {"text": {"literalString": "Book Your Table"}, "usageHint": "h1"}}}, {"id": "date-picker", "component": {"DateTimeInput": {"label": {"literalString": "Select Date"}, "value": {"path": "/reservation/date"}, "enableDate": true}}}, {"id": "submit-text", "component": {"Text": {"text": {"literalString": "Confirm Reservation"}}}}, {"id": "submit-btn", "component": {"Button": {"child": "submit-text", "action": {"name": "confirm_booking"}}}}]}}```
**Populating data:**
```json{"dataModelUpdate": {"surfaceId": "main", "contents": [ {"key": "reservation", "valueMap": [ {"key": "date", "valueString": "2025-12-15"}, {"key": "time", "valueString": "19:00"}, {"key": "guests", "valueInt": 2} ]}]}}```
**Signaling render:**
```json{"beginRendering": {"surfaceId": "main", "root": "header"}}```=== “v0.9 (Draft)”
**Creating the surface:**
```json{"version": "v0.9", "createSurface": {"surfaceId": "main", "catalogId": "https://a2ui.org/specification/v0_9/basic_catalog.json"}}```
**Defining the UI:**
```json{"version": "v0.9", "updateComponents": {"surfaceId": "main", "components": [ {"id": "header", "component": "Text", "text": "# Book Your Table", "variant": "h1"}, {"id": "date-picker", "component": "DateTimeInput", "label": "Select Date", "value": {"path": "/reservation/date"}, "enableDate": true}, {"id": "submit-text", "component": "Text", "text": "Confirm Reservation"}, {"id": "submit-btn", "component": "Button", "child": "submit-text", "variant": "primary", "action": {"event": {"name": "confirm_booking"}}}]}}```
**Populating data:**
```json{"version": "v0.9", "updateDataModel": {"surfaceId": "main", "path": "/reservation", "value": {"date": "2025-12-15", "time": "19:00", "guests": 2}}}```
Note: In v0.9, `createSurface` replaces `beginRendering`, components use a flatter format, and the data model uses plain JSON values instead of typed adjacency lists.💡 It’s Just JSON
Notice how readable and structured this is? LLMs can generate this easily, and it’s safe to transmit and render—no code execution required.
Exploring Other Demos
Section titled “Exploring Other Demos”The repository includes several other demos:
Component Gallery (No Agent Required)
Section titled “Component Gallery (No Agent Required)”See all available A2UI components:
npm start -- galleryThis runs a client-only demo showcasing every standard component (Card, Button, TextField, Timeline, etc.) with live examples and code samples.
Contact Lookup Demo
Section titled “Contact Lookup Demo”Try a different agent use case:
npm run demo:contactThis demonstrates a contact lookup agent that generates search forms and result lists.
What’s Next?
Section titled “What’s Next?”Now that you’ve seen A2UI in action, you’re ready to:
- Learn Core Concepts: Understand surfaces, components, and data binding
- Set Up Your Own Client: Integrate A2UI into your own app
- Build an Agent: Create agents that generate A2UI responses
- Explore the Protocol: Dive into the technical specification
Troubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”If port 5173 is already in use, the dev server will automatically try the next available port. Check the terminal output for the actual URL.
API Key Issues
Section titled “API Key Issues”If you see errors about missing API keys:
- Verify the key is exported:
echo $GEMINI_API_KEY - Make sure it’s a valid Gemini API key from Google AI Studio
- Try re-exporting:
export GEMINI_API_KEY="your_key"
Connection Errors on Startup
Section titled “Connection Errors on Startup”If you see ERR_CONNECTION_REFUSED errors when the browser opens, don’t worry — this is a known race condition (#587). The web app starts faster than the Python agent backend. Just wait a few seconds and refresh the page.
Python / uv Issues
Section titled “Python / uv Issues”The demo agents require uv to run. If you see uv: command not found:
# Install uvcurl -LsSf https://astral.sh/uv/install.sh | sh
# Verifyuv --versionIf you encounter other Python errors:
# Make sure Python 3.10+ is availablepython3 --version
# Try running the agent manuallycd samples/agent/adk/restaurant_finderuv run .Still Having Issues?
Section titled “Still Having Issues?”- Check the GitHub Issues
- Review the samples/client/lit/README.md
- Join the community discussions
Understanding the Demo Code
Section titled “Understanding the Demo Code”Want to see how it works? Check out:
- Agent Code:
samples/agent/adk/restaurant_finder/— The Python A2A agent - Client Code:
samples/client/lit/— The Lit web client with A2UI renderer - A2UI Renderers:
renderers/lit/(Lit) andrenderers/web_core/(framework-agnostic core)
Each directory has its own README with detailed documentation.
Congratulations! You’ve successfully run your first A2UI application. You’ve seen how an AI agent can generate rich, interactive UIs that render natively in a web application—all through safe, declarative JSON messages.