Package com.sap.ai.sdk.foundationmodels.openai

# Class OpenAiUserMessage

java.lang.Object
com.sap.ai.sdk.foundationmodels.openai.OpenAiUserMessage

All Implemented Interfaces:
  `OpenAiMessage`

public final class OpenAiUserMessage extends Object implements OpenAiMessage
Represents a chat message as 'user' to OpenAI service. *

Since:
  1.4.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `OpenAiMessageContent`
  `content()`
  The content of the message.
  `boolean`
  `equals(Object o)`
  `int`
  `hashCode()`
  `String`
  `role()`
  The role associated with this message.
  `String`
  `toString()`
  `OpenAiUserMessage`
  `withImage(String imageUrl)`
  Add an image to the message with the given image URL.
  `OpenAiUserMessage`
  `withImage(String imageUrl, OpenAiImageItem.DetailLevel detailLevel)`
  Add an image to the message with the given image URL and detail level.
  `OpenAiUserMessage`
  `withText(String message)`
  Add text to the message.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### withText

    @Nonnull public OpenAiUserMessage withText(@Nonnull String message)
    Add text to the message.
    Parameters:
      `message` - the text to add.
    Returns:
      the new message.

  - ### withImage

    @Nonnull public OpenAiUserMessage withImage(@Nonnull String imageUrl, @Nonnull OpenAiImageItem.DetailLevel detailLevel)
    Add an image to the message with the given image URL and detail level.
    Parameters:
      `imageUrl` - the URL of the image.
      `detailLevel` - the detail level of the image.
    Returns:
      the new message.

  - ### withImage

    @Nonnull public OpenAiUserMessage withImage(@Nonnull String imageUrl)
    Add an image to the message with the given image URL.
    Parameters:
      `imageUrl` - the URL of the image.
    Returns:
      the new message.

  - ### role

    @Nonnull public String role()
    The role associated with this message.
    Specified by:
      `role` in interface `OpenAiMessage`
    Returns:
      the role.

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### content

    @Nonnull public OpenAiMessageContent content()
    The content of the message.
    Specified by:
      `content` in interface `OpenAiMessage`
    Returns:
      the content.