Message Types
Message
Message
Letta’s internal representation of a message. Includes methods to convert to/from LLM provider formats.
Attributes:
id
str - The unique identifier of the message.role
MessageRole - The role of the participant.text
str - The text of the message.user_id
str - The unique identifier of the user.agent_id
str - The unique identifier of the agent.model
str - The model used to make the function call.name
str - The name of the participant.created_at
datetime - The time the message was created.tool_calls
List[ToolCall] - The list of tool calls requested.tool_call_id
str - The id of the tool call.
to_letta_message
Convert message object (in DB format) to the style used by the original Letta API
dict_to_message
Convert a ChatCompletion message object into a Message object (synced to DB)
to_openai_dict
Go from Message class to ChatCompletion message object
to_anthropic_dict
Convert to an Anthropic message dictionary
Arguments:
inner_thoughts_xml_tag
str - The XML tag to wrap around inner thoughts
to_google_ai_dict
Go from Message class to Google AI REST message object
to_cohere_dict
Cohere chat_history dicts only have ‘role’ and ‘message’ fields