Class Message

  • All Implemented Interfaces:

    
    public final class Message
    
                        

    A message to or from the model.

    • Constructor Detail

    • Method Detail

      • id

         final String id()

        The unique ID of the message.

      • role

         final Message.Role role()

        The role of the message. One of unknown, user, assistant, system, critic, discriminator, developer, or tool.

      • status

         final Message.Status status()

        The status of item. One of in_progress, completed, or incomplete. Populated when items are returned via API.

      • _type

         final JsonValue _type()

        The type of the message. Always set to message.

        Expected to always return the following:

        JsonValue.from("message")

        However, this method can be useful for debugging and logging (e.g. if the server responded with an unexpected value).

      • phase

         final Optional<Message.Phase> phase()

        Labels an assistant message as intermediate commentary (commentary) or the final answer (final_answer). For models like gpt-5.3-codex and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages.

      • _id

         final JsonField<String> _id()

        Returns the raw JSON value of id.

        Unlike id, this method doesn't throw if the JSON field has an unexpected type.

      • validate

         final Message validate()

        Validates that the types of all values in this object match their expected types recursively.

        This method is not forwards compatible with new types from the API for existing fields.

      • builder

         final static Message.Builder builder()

        Returns a mutable builder for constructing an instance of Message.

        The following fields are required:

        .id()
        .content()
        .role()
        .status()