Observed since 21 Oct, 09:32 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
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.
pip install ag-ui-protocol
poetry add ag-ui-protocol
pipenv install ag-ui-protocol
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
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.
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.
ag_ui.core – Types, events, and data models for AG-UI protocolag_ui.encoder – Event encoding utilities for HTTP streamingdocs/conceptsdocs/sdk/pythonBug reports and pull requests are welcome! Please read our contributing guide first.
MIT © 2025 AG-UI Protocol Contributors
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 17 Sept 2026 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 09:32 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:afadbac6016fd27ad93e6fadf2681707dd8a7bbe9ff1ae8bb5792dc889f6b917