struct
OpenRouter::Message
- OpenRouter::Message
- Struct
- Value
- Object
Included Modules
- JSON::Serializable
Defined in:
openrouter/types/message.crConstructors
-
.new(role : Role, content : Content | Nil, name : String | Nil = nil, tool_call_id : String | Nil = nil, tool_calls : Array(ToolCall) | Nil = nil, reasoning : String | Nil = nil, reasoning_details : JSON::Any | Nil = nil)
Initialize for user/assistant/system messages
- .new(pull : JSON::PullParser)
-
.new(tool_call : ToolCall)
Create a tool result message.
Class Method Summary
Instance Method Summary
- #add_tool_call(tool_call : ToolCall)
- #add_tool_call(name : String, arguments : Array(ToolCallArgument) = [] of ToolCallArgument, tool_call_type : String = "function", tool_call_id : String | Nil = nil)
- #content : Content | Nil
- #content=(content : Content | Nil)
-
#content_string : String
Get the content, or in case of a multi-modal message, the content of the first part.
- #length : Int32
-
#multi_modal? : Bool
Check if content is an Array
- #name : String | Nil
- #name=(name : String | Nil)
-
#reasoning : String | Nil
Reasoning tokens - visible reasoning trace from the model
-
#reasoning=(reasoning : String | Nil)
Reasoning tokens - visible reasoning trace from the model
-
#reasoning_details : JSON::Any | Nil
Reasoning details for preserving reasoning blocks (used in tool calling)
-
#reasoning_details=(reasoning_details : JSON::Any | Nil)
Reasoning details for preserving reasoning blocks (used in tool calling)
-
#role : Role | Nil
Common fields
-
#role=(role : Role | Nil)
Common fields
-
#to_json(json : JSON::Builder)
Custom serialization for complex multi-modal content and tool calls
-
#tool_call_id : String | Nil
Optional fields for specific roles
-
#tool_call_id=(tool_call_id : String | Nil)
Optional fields for specific roles
- #tool_calls : Array(ToolCall) | Nil
- #tool_calls=(tool_calls : Array(ToolCall) | Nil)
Constructor Detail
Initialize for user/assistant/system messages
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 Method Detail
Instance Method Detail
Get the content, or in case of a multi-modal message, the content of the first part.
Reasoning tokens - visible reasoning trace from the model
Reasoning details for preserving reasoning blocks (used in tool calling)
Reasoning details for preserving reasoning blocks (used in tool calling)
Custom serialization for complex multi-modal content and tool calls