Overview
TheMessage class represents individual messages in a conversation, supporting various roles (system, user, assistant, tool), rich content types, attachments, and detailed metrics.
Creating Messages
Basic messages
Tool messages
Key properties
string
default:"auto-generated"
Unique identifier based on content hash
Literal['system', 'user', 'assistant', 'tool']
required
The role of the message sender
str | List[TextContent | ImageContent]
default:"None"
Message content - can be text or multimodal content
string
Name identifier for tool messages
string
Required for tool role messages to link to the tool call
List[Dict]
Tool calls made by assistant messages
datetime
default:"now"
When the message was created (UTC)
int
Message order within the thread (set automatically)
int
Conversational turn number (set automatically)
List[Attachment]
default:"[]"
File attachments on the message
Dict[str, List[str]]
default:"{}"
Emoji reactions - maps emoji to list of user IDs
EntitySource
Information about who/what created this message
Dict[str, Dict[str, str]]
default:"{}"
Platform-specific identifiers (e.g., Slack message ID)
Dict[str, Any]
Performance and usage metrics for the message