Observed since 20 Oct, 16:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A2UI Pydantic Schema
A Python implementation of the A2UI (Agent to UI) protocol using Pydantic. This library provides type-safe, validated models for building AI agent interfaces that render natively across web, mobile, and desktop platforms.
A2UI is a protocol that enables AI agents to generate rich, interactive user interfaces through declarative component descriptions. Instead of executing arbitrary code, agents send structured JSON messages that clients render using their own native widgets. Learn more at a2ui.org.
uv add a2ui-pydantic
pip install a2ui-pydantic
git clone https://github.com/nurokhq/a2ui-pydantic.git
cd a2ui-pydantic
uv sync --all-groups
from a2ui_pydantic import (
A2UIMessage,
BeginRendering,
SurfaceUpdate,
SurfaceComponent,
ComponentWrapper,
TextComponent,
ButtonComponent,
Action,
Styles,
)
# Create a begin rendering message
message = A2UIMessage(
beginRendering=BeginRendering(
surfaceId="main",
root="header",
styles=Styles(
font="Roboto",
primaryColor="#00BFFF"
)
)
)
# Create a surface with components
text_comp = TextComponent(
text={"literalString": "Welcome to A2UI"},
usageHint="h1"
)
button_comp = ButtonComponent(
child="button-text",
action=Action(name="submit", context=[])
)
update_message = A2UIMessage(
surfaceUpdate=SurfaceUpdate(
surfaceId="main",
components=[
SurfaceComponent(
id="header",
component=ComponentWrapper(Text=text_comp)
),
SurfaceComponent(
id="button-text",
component=ComponentWrapper(Text=TextComponent(
text={"literalString": "Click Me"}
))
),
SurfaceComponent(
id="submit-btn",
component=ComponentWrapper(Button=button_comp)
)
]
)
)
# Serialize to JSON
import json
print(json.dumps(message.model_dump(by_alias=True), indent=2))
from a2ui_pydantic import (
DataModelUpdate,
DataModelEntry,
TextComponent,
)
# Update data model
data_update = DataModelUpdate(
surfaceId="main",
path="/user",
contents=[
DataModelEntry(key="name", valueString="Alice"),
DataModelEntry(key="age", valueNumber=30),
]
)
# Reference data in components
text_with_binding = TextComponent(
text={"path": "/user/name"} # Binds to data model
)
a2ui_pydantic/
├── __init__.py # Public API exports
├── base.py # Base models (Literal*OrPath, etc.)
├── components.py # All 18 component types
├── messages.py # Message types (A2UIMessage, etc.)
├── data_model.py # Data model structures
├── actions.py # Action and context models
└── enums.py # Enumeration types
# Clone the repository
git clone https://github.com/nurokhq/a2ui-pydantic.git
cd a2ui-pydantic
# Install with dev dependencies
uv sync --all-groups
# Run all tests
uv run pytest tests/
# Run with coverage
uv run pytest tests/ --cov=a2ui_pydantic --cov-report=term
# Run specific test file
uv run pytest tests/test_components.py
# Run pylint
uv run pylint a2ui_pydantic tests
# Run mypy
uv run mypy a2ui_pydantic tests
# Run bandit (security)
uv run bandit -r a2ui_pydantic
The library supports all A2UI v0.8 components:
Content Components:
TextComponent - Text with usage hints (h1-h5, body, caption)ImageComponent - Images with fit modes and usage hintsIconComponent - Icons from the A2UI icon setVideoComponent - Video playbackAudioPlayerComponent - Audio playback with descriptionLayout Components:
RowComponent - Horizontal layout with distribution/alignmentColumnComponent - Vertical layout with distribution/alignmentListComponent - List with direction (vertical/horizontal)CardComponent - Card containerTabsComponent - Tabbed interfaceDividerComponent - Visual separatorModalComponent - Modal dialogForm Components:
ButtonComponent - Button with actionsCheckBoxComponent - Checkbox inputTextFieldComponent - Text input (short/long/obscured/number/date)DateTimeInputComponent - Date and time pickerMultipleChoiceComponent - Multi-select optionsSliderComponent - Numeric sliderBeginRendering - Initialize a new surface with root component and stylesSurfaceUpdate - Update or create a surface with componentsDataModelUpdate - Update the data model for a surfaceDeleteSurface - Remove a surfaceComponents support two value types:
{"literalString": "Hello"}){"path": "/user/name"})This enables dynamic UIs where component values are bound to a data model that can be updated independently.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request to the GitHub repository.
This library implements the A2UI v0.8 (Stable) specification. The A2UI protocol is currently in public preview and may evolve. This library will be updated to track specification changes.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.1 | 26 Dec 2025 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 16:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d58ce3980bd8e4264da39e10115c0abcbae7730367afcc87900c64c633c67b17