Usage
Signature
Parameters
Literal['user', 'assistant', 'system']
required
The role of the message.
Any
required
The content of the message. This can be a rich Python object.
str
default:"''"
The id of the message.
list[ChatPart]
default:"[]"
Parts from AI SDK Stream Protocol (must be serializable to JSON).
Optional[list[ChatAttachment]]
default:"None"
Optional attachments to the message.
Any | None
default:"None"
Optional metadata.
Part Types
TextPart
Represents a text content part. Attributes:type(Literal[“text”]): Part typetext(str): The text content
ReasoningPart
Represents a reasoning content part. Attributes:type(Literal[“reasoning”]): Part typetext(str): The reasoning textdetails(Optional[list[ReasoningDetails]]): Optional reasoning details
ToolInvocationPart
Represents a tool invocation part from the AI SDK. Attributes:type(str): Starts with “tool-”tool_call_id(str): The tool call identifierstate(Union[str, Literal[“output-available”]]): The state of the invocationinput(dict[str, Any]): The input to the tooloutput(Optional[Any]): The output from the tool
tool_name: Returns the tool name (extracted from type)
FilePart
Represents a FileUIPart from the AI SDK. Attributes:type(Literal[“file”]): Part typemedia_type(str): The media typeurl(str): The file URLfilename(Optional[str]): Optional filename