Class: AssistantMessage
@providerprotocol/ai / @providerprotocol/ai / AssistantMessage
Class: AssistantMessage
Section titled “Class: AssistantMessage”Defined in: src/types/messages.ts:263
Assistant response message.
Represents a response from the AI assistant, which may contain text, media content, and/or tool call requests.
Example
Section titled “Example”// Simple text responseconst msg = new AssistantMessage('Hello! How can I help?');
// Response with tool callsconst msg = new AssistantMessage( 'Let me check the weather...', [{ toolCallId: 'call_1', toolName: 'get_weather', arguments: { location: 'NYC' } }]);Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AssistantMessage(
content,toolCalls?,options?):AssistantMessage
Defined in: src/types/messages.ts:280
Creates a new assistant message.
Parameters
Section titled “Parameters”content
Section titled “content”String (converted to TextBlock) or array of content blocks
string | AssistantContent[]
toolCalls?
Section titled “toolCalls?”ToolCall[]
Tool calls requested by the model
options?
Section titled “options?”Optional message ID and metadata
Returns
Section titled “Returns”AssistantMessage
Overrides
Section titled “Overrides”Properties
Section titled “Properties”content
Section titled “content”
readonlycontent:AssistantContent[]
Defined in: src/types/messages.ts:268
Content blocks in this message
readonlyid:string
Defined in: src/types/messages.ts:124
Unique message identifier
Inherited from
Section titled “Inherited from”metadata?
Section titled “metadata?”
readonlyoptionalmetadata:MessageMetadata
Defined in: src/types/messages.ts:130
Provider-specific metadata, namespaced by provider name
Inherited from
Section titled “Inherited from”timestamp
Section titled “timestamp”
readonlytimestamp:Date
Defined in: src/types/messages.ts:127
Timestamp when the message was created
Inherited from
Section titled “Inherited from”toolCalls?
Section titled “toolCalls?”
readonlyoptionaltoolCalls:ToolCall[]
Defined in: src/types/messages.ts:271
Tool calls requested by the model (if any)
readonlytype:"assistant"
Defined in: src/types/messages.ts:265
Message type discriminator
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get audio():
AudioBlock[]
Defined in: src/types/messages.ts:180
All audio content blocks in this message.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”documents
Section titled “documents”Get Signature
Section titled “Get Signature”get documents():
DocumentBlock[]
Defined in: src/types/messages.ts:173
All document content blocks in this message.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”hasToolCalls
Section titled “hasToolCalls”Get Signature
Section titled “Get Signature”get hasToolCalls():
boolean
Defined in: src/types/messages.ts:301
Whether this message contains tool call requests.
Returns
Section titled “Returns”boolean
images
Section titled “images”Get Signature
Section titled “Get Signature”get images():
ImageBlock[]
Defined in: src/types/messages.ts:166
All image content blocks in this message.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”reasoning
Section titled “reasoning”Get Signature
Section titled “Get Signature”get reasoning():
ReasoningBlock[]
Defined in: src/types/messages.ts:195
All reasoning/thinking content blocks in this message. Available when using extended thinking models.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get text():
string
Defined in: src/types/messages.ts:156
Concatenated text content from all text blocks. Blocks are joined with double newlines.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get video():
VideoBlock[]
Defined in: src/types/messages.ts:187
All video content blocks in this message.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”getContent()
Section titled “getContent()”
protectedgetContent():ContentBlock[]
Defined in: src/types/messages.ts:294
Returns the content blocks for this message. Implemented by subclasses to provide type-specific content.