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

# Interface OpenAiMessage

All Known Implementing Classes:
  `OpenAiAssistantMessage`, `OpenAiSystemMessage`, `OpenAiToolMessage`, `OpenAiUserMessage`

public sealed interface OpenAiMessage permits OpenAiUserMessage, OpenAiAssistantMessage, OpenAiSystemMessage, OpenAiToolMessage
Interface representing convenience wrappers of chat message to the openai service.

Since:
  1.4.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static OpenAiAssistantMessage`
  `assistant(String message)`
  A convenience method to create an assistant message.
  `static OpenAiAssistantMessage`
  `assistant(List<OpenAiToolCall> toolCalls)`
  A convenience method to create an assistant message.
  `OpenAiMessageContent`
  `content()`
  Returns the content of the message.
  `String`
  `role()`
  Returns the role associated with the message.
  `static OpenAiSystemMessage`
  `system(String message)`
  A convenience method to create a system message.
  `static OpenAiToolMessage`
  `tool(String message, String toolCallId)`
  A convenience method to create a tool message.
  `static OpenAiUserMessage`
  `user(OpenAiImageItem openAiImageItem)`
  A convenience method to create a user message containing only an image.
  `static OpenAiUserMessage`
  `user(String message)`
  A convenience method to create a user message.

- ## Method Details

  - ### user

    @Nonnull static OpenAiUserMessage user(@Nonnull String message)
    A convenience method to create a user message.
    Parameters:
      `message` - the message content.
    Returns:
      the user message.

  - ### user

    @Nonnull static OpenAiUserMessage user(@Nonnull OpenAiImageItem openAiImageItem)
    A convenience method to create a user message containing only an image.
    Parameters:
      `openAiImageItem` - the message content.
    Returns:
      the user message.

  - ### assistant

    @Nonnull static OpenAiAssistantMessage assistant(@Nonnull String message)
    A convenience method to create an assistant message.
    Parameters:
      `message` - the message content.
    Returns:
      the assistant message.

  - ### assistant

    @Nonnull static OpenAiAssistantMessage assistant(@Nonnull List<OpenAiToolCall> toolCalls)
    A convenience method to create an assistant message.
    Parameters:
      `toolCalls` - tool calls to associate with the message.
    Returns:
      the assistant message.

  - ### system

    @Nonnull static OpenAiSystemMessage system(@Nonnull String message)
    A convenience method to create a system message.
    Parameters:
      `message` - the message content.
    Returns:
      the system message.

  - ### tool

    @Nonnull static OpenAiToolMessage tool(@Nonnull String message, @Nonnull String toolCallId)
    A convenience method to create a tool message.
    Parameters:
      `message` - response of the executed tool call.
      `toolCallId` - identifier of the tool call that the assistant expected.
    Returns:
      the tool message.

  - ### role

    @Nonnull String role()
    Returns the role associated with the message.
    Returns:
      the role.

  - ### content

    @Nonnull OpenAiMessageContent content()
    Returns the content of the message.
    Returns:
      the content.