This release is a pre-release and may not be stable for production use.
ag-ui-protocol
Python SDK for the Agent-User Interaction (AG-UI) Protocol.
ag-ui-protocol provides Python developers with strongly-typed data structures and event encoding for building AG-UI compatible agent servers. Built on Pydantic for robust validation and automatic camelCase serialization for seamless frontend integration.
Installation
pip install ag-ui-protocol
poetry add ag-ui-protocol
pipenv install ag-ui-protocol
Features
- 🐍 Python-native – Idiomatic Python APIs with full type hints and validation
- 📋 Pydantic models – Runtime validation and automatic JSON serialization
- 🔄 Streaming events – 16 core event types for real-time agent communication
- ⚡ High performance – Efficient event encoding for Server-Sent Events
Quick example
from ag_ui.core import TextMessageContentEvent, EventType
from ag_ui.encoder import EventEncoder
# Create a streaming text event
event = TextMessageContentEvent(
type=EventType.TEXT_MESSAGE_CONTENT,
message_id="msg_123",
delta="Hello from Python!"
)
# Encode for HTTP streaming
encoder = EventEncoder()
sse_data = encoder.encode(event)
# Output: data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"msg_123","delta":"Hello from Python!"}\n\n
Multimodal user message
from ag_ui.core import UserMessage, TextInputContent, ImageInputPart, InputContentUrlSource
message = UserMessage(
id="user-123",
content=[
TextInputContent(text="Please describe this image"),
ImageInputPart(
source=InputContentUrlSource(
value="https://example.com/cat.png",
mime_type="image/png",
)
),
],
)
payload = message.model_dump(by_alias=True)
# {"id": "user-123", "role": "user", "content": [...]}
BinaryInputContentis deprecated. Use modality-specific input parts (ImageInputPart,AudioInputPart,VideoInputPart,DocumentInputPart) withInputContentDataSourceorInputContentUrlSource.
Optional fields with no value are left out
Serializing an AG-UI type omits every optional field that has no value instead of writing it as
null — matching what a TypeScript producer puts on the wire. This is built into the base model, so
it holds on every path (model_dump, model_dump_json, nesting inside another model, the
EventEncoder) and you do not need to pass exclude_none=True:
from ag_ui.core import ToolCallStartEvent
ToolCallStartEvent(tool_call_id="tc_1", tool_call_name="search").model_dump_json(by_alias=True)
# {"type":"TOOL_CALL_START","toolCallId":"tc_1","toolCallName":"search"}
# note: no "parentMessageId": null
null as an actual value is untouched: a required field holding None, a None inside a dict or
list (an individual metadata value, a JSON Patch replace with null), and any extra field all
serialize as null.
Packages
ag_ui.core– Types, events, and data models for AG-UI protocolag_ui.encoder– Event encoding utilities for HTTP streaming
Documentation
- Concepts & architecture:
docs/concepts - Full API reference:
docs/sdk/python
Contributing
Bug reports and pull requests are welcome! Please read our contributing guide first.
License
MIT © 2025 AG-UI Protocol Contributors
Metadata
Release files for ag-ui-protocol 1.0.0.dev1789569879
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ag_ui_protocol-1.0.0.dev1789569879.tar.gz | 30.0 kB | Without provenance | Details for ag_ui_protocol-1.0.0.dev1789569879.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ag_ui_protocol-1.0.0.dev1789569879-py3-none-any.whl | Python 3 | none | any | Details for ag_ui_protocol-1.0.0.dev1789569879-py3-none-any.whl |
Total release size: 66.0 kB
Release files / ag_ui_protocol-1.0.0.dev1789569879.tar.gz
| Download URL | ag_ui_protocol-1.0.0.dev1789569879.tar.gz |
|---|---|
| Size | 30.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f90b03acb0683616a16b06c3d892ce99429fb72223d5b4c006994ae199e7c0de
|
|
BLAKE2b-256 checksum How to use checksums |
d93a565ab2a6eefea84cfe73b6e33393e3644efd471b7e53656dc063033e02f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ag_ui_protocol-1.0.0.dev1789569879-py3-none-any.whl
| Download URL | ag_ui_protocol-1.0.0.dev1789569879-py3-none-any.whl |
|---|---|
| Size | 36.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4ef8821e6a97def2b1b0603eea5a4f8c77906be3552e7c0a9ae02095912e1c3
|
|
BLAKE2b-256 checksum How to use checksums |
b985366a9a8c49e60ffc6b68253849907cc1990b7744f8faeffc7281225037e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ag-ui-protocol 1.0.0.dev1789569879
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.