OpenRouter::Message
Inherits JSON::Serializable < Struct < Value < Object
Constructors
Initialize for user/assistant/system messages
Override JSON::Serializable's generated self.new(pull) so that response deserialization routes through our custom from_json(JSON::Any), which correctly handles the nested image_url/video_url format from the API.
Create a tool result message.
Role will be Role::Tool @name will be set to tool_call.name @tool_call_id will be set to tool_call.id @content will be set to serializd string of tool_call.arguments.to_json()
Class methods
Instance methods
Get the content, or in case of a multi-modal message, the content of the first part.
Returns image URLs from the message — either from a separate images
field (some models) or from image_url content parts (others).
Generated images returned by image generation models.
Each entry is an object, typically {"url": "data:image/png;base64,..."}.
Generated images returned by image generation models.
Each entry is an object, typically {"url": "data:image/png;base64,..."}.
Reasoning tokens - visible reasoning trace from the model
Reasoning details for preserving reasoning blocks (used in tool calling)
Custom serialization for complex multi-modal content and tool calls