Ruby SDK for the Agent-User Interaction (AG-UI) Protocol.
ag-ui-protocol provides Ruby developers with strongly-typed data structures and event encoding for building AG-UI compatible agent servers. Built on Sorbet for robust validation and automatic camelCase serialization for seamless frontend integration.
Install bundle:
gem install bundlerAdd the gem:
bundle add ag-ui-protocol- 🐍 Ruby-native – Ruby APIs with full type hints and validation
- 📋 Sorbet Runtime – Runtime validation scheme
- 🔄 Streaming events – 16 core event types for real-time agent communication
- ⚡ High performance – Efficient event encoding for Server-Sent Events
require "ag_ui_protocol"
event = AgUiProtocol::Core::Events::TextMessageContentEvent.new(
message_id: "msg_123",
delta: "Hello from Ruby!",
)
encoder = AgUiProtocol::Encoder::EventEncoder.new
encoded_event = encoder.encode(event)require "ag_ui_protocol/core/types"
message = AgUiProtocol::Core::Types::UserMessage.new(
id: "user-123",
content: [
{ type: "text", text: "Please describe this image" },
{ type: "binary", mimeType: "image/png", url: "https://example.com/a.png" }
# or
AgUiProtocol::Core::Types::TextInputContent.new(text: "Please describe this image"),
AgUiProtocol::Core::Types::BinaryInputContent.new(mime_type: "image/png", url: "https://example.com/cat.png"),
],
)AgUiProtocol::Core::Types– Message types, tools, and data modelsAgUiProtocol::Core::Events– Event types and event handlingAgUiProtocol::Encoder– Event encoding utilities for HTTP streaming
- Concepts & architecture:
docs/concepts - Full API reference:
docs/sdk/ruby
See the example/ directory for:
To sync the documentation of YARD with the path docs/sdk/ruby, run the following command:
cd sdks/community/ruby
rake doccd sdks/community/ruby
rake testBug reports and pull requests are welcome! Please read our contributing guide first.
MIT © 2025 AG-UI Protocol Contributors