Member Junction
    Preparing search index...

    Type Alias ChatMessage<M>

    Defines the shape of an individual chat message.

    type ChatMessage<M = any> = {
        content: ChatMessageContent;
        metadata?: M;
        role: ChatMessageRole;
        toolCalls?: ChatToolCall[];
    }

    Type Parameters

    • M = any

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

    Hierarchy (View Summary)

    Index

    Properties

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

    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 of the message in the conversation.

    toolCalls?: ChatToolCall[]

    For assistant turns that called tools: the calls the model made, so a prior tool-calling turn round-trips back to the provider on the next request. Every provider requires the assistant's own call turn to be present in history before the matching results.

    Set this from ChatCompletionMessage.toolCalls when appending the model's reply to the conversation; the tool turn that answers it follows immediately.