Title: ModelMessage
Published: May 20, 2026

---

# class ModelMessage {}

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#description)
 * [Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#methods)
 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#wp--skip-link--target)

Represents a message from the AI model.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#description)󠁿

This is a convenience class that automatically sets the role to MODEL.
Model messages
contain the AI’s responses.

Important: Do not rely on `instanceof ModelMessage` to determine the message role.

This is merely a helper class for construction. Always use `$message->getRole()`
to check the role of a message.

## 󠀁[Methods](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#methods)󠁿

| Name | Description | 
| [ModelMessage::__construct](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/__construct/) | Constructor. |

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#source)󠁿

    ```php
    class ModelMessage extends \WordPress\AiClient\Messages\DTO\Message
    {
        /**
         * Constructor.
         *
         * @since 0.1.0
         *
         * @param MessagePart[] $parts The parts that make up this message.
         */
        public function __construct(array $parts)
        {
            parent::__construct(MessageRoleEnum::model(), $parts);
        }
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/messages/dto/modelmessage.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/src/Messages/DTO/ModelMessage.php#L19)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/src/Messages/DTO/ModelMessage.php#L19-L32)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-messages-dto-modelmessage/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.1.0](https://developer.wordpress.org/reference/since/0.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclient-messages-dto-modelmessage%2F)
before being able to contribute a note or feedback.