Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/core/llms.txt
Use this file to discover all available pages before exploring further.
Message is the immutable value object that represents a single turn in a conversation. Every generation request is ultimately a sequence of Message instances. A message carries a role (user, assistant, system, or tool), an array of typed Content parts, and optional metadata such as a tool call ID or pending tool calls. Use the static factory methods to construct messages; the constructor is private.
Constants
| Constant | Value |
|---|---|
Message::ROLE_SYSTEM | 'system' |
Message::ROLE_USER | 'user' |
Message::ROLE_ASSISTANT | 'assistant' |
Message::ROLE_TOOL | 'tool' |
Factory methods
user()
Create a user-role message. Accepts a plain string or an array of Content objects for multi-part messages (e.g. text + image).
A plain string — automatically wrapped in a single
Content::text() part — or an array of Content instances. Throws InvalidArgumentException if any array element is not a Content instance.assistant()
Create an assistant-role message, optionally with pending tool calls.
The assistant’s text response, or an array of
Content parts.An array of
ToolCall value objects representing tool invocations the model requested in this turn.system()
Create a system-role message that provides instructions or context before the conversation begins.
The system instruction text. Wrapped in a single
Content::text() part internally.tool()
Create a tool-result message that delivers the output of a tool call back to the model.
The identifier of the tool call this result corresponds to, matching the
ToolCall::id from the model’s previous response.The serialised tool output. Non-string results should be JSON-encoded before passing here.
The name of the tool that was called. Some providers require this field.
Properties
The conversation role. One of
'user', 'assistant', 'system', or 'tool'. Use the ROLE_* constants for safe comparisons.An indexed array of
Content parts that make up the message body. Always contains at least one element.The tool name associated with a
'tool'-role message, or null for other roles.The tool call ID for a
'tool'-role message, linking this result to the model’s prior tool invocation. null for other roles.An indexed array of
ToolCall objects present on 'assistant'-role messages. Empty for all other roles.Methods
text()
Concatenate and return the text of all Content::TYPE_TEXT parts in this message.
A single string formed by concatenating the
textValue() of every text-type content part. Returns an empty string if there are no text parts.