ChatMessage<M>: {
    content: ChatMessageContent;
    metadata?: M;
    role: ChatMessageRole;
}

Defines the shape of an individual chat message.

Type Parameters

  • M = any

    Optional metadata type. Use this to attach typed metadata to messages without coupling the core ChatMessage type to specific implementations.

Type declaration

  • content: ChatMessageContent

    Content of the message, can be any string or an array of content blocks.

  • Optional metadata?: M

    Optional metadata for the message. The type can be specified via the generic parameter. This allows different consumers to attach their own typed metadata without modifying the core ChatMessage type.

  • role: ChatMessageRole

    Role of the message in the conversation.