Skip to main content
A message in a chat.

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 type
  • text (str): The text content

ReasoningPart

Represents a reasoning content part. Attributes:
  • type (Literal[“reasoning”]): Part type
  • text (str): The reasoning text
  • details (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 identifier
  • state (Union[str, Literal[“output-available”]]): The state of the invocation
  • input (dict[str, Any]): The input to the tool
  • output (Optional[Any]): The output from the tool
Properties:
  • tool_name: Returns the tool name (extracted from type)

FilePart

Represents a FileUIPart from the AI SDK. Attributes:
  • type (Literal[“file”]): Part type
  • media_type (str): The media type
  • url (str): The file URL
  • filename (Optional[str]): Optional filename