ag-ui-protocol

17 个版本 Python >=3.9
Markus Ecker <Markus Ecker <markus.ecker@gmail.com>>
安装
pip install ag-ui-protocol
poetry add ag-ui-protocol
pipenv install ag-ui-protocol
conda install ag-ui-protocol
描述

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": [...]}

BinaryInputContent is deprecated. Use modality-specific input parts (ImageInputPart, AudioInputPart, VideoInputPart, DocumentInputPart) with InputContentDataSource or InputContentUrlSource.

Packages

  • ag_ui.core – Types, events, and data models for AG-UI protocol
  • ag_ui.encoder – Event encoding utilities for HTTP streaming

Documentation

Contributing

Bug reports and pull requests are welcome! Please read our contributing guide first.

License

MIT © 2025 AG-UI Protocol Contributors

版本列表
0.1.19 2026-06-02
0.1.18 2026-04-21
0.1.17 2026-04-20
0.1.16 2026-04-17
0.1.15 2026-04-01
0.1.14 2026-03-18
0.1.13 2026-02-19
0.1.12 2026-02-19
0.1.11 2026-02-11
0.1.10 2025-11-06
0.1.9 2025-09-19
0.1.8 2025-07-15
0.1.7 2025-06-26
0.1.6 2025-06-26
0.1.5 2025-05-20
0.1.4 2025-04-30
0.1.9a0 2025-09-05