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

# Class OpenAiChatModel

java.lang.Object
com.sap.ai.sdk.foundationmodels.openai.spring.OpenAiChatModel

All Implemented Interfaces:
  `org.springframework.ai.chat.model.ChatModel`, `org.springframework.ai.chat.model.StreamingChatModel`, `org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>`, `org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>`

public class OpenAiChatModel extends Object implements org.springframework.ai.chat.model.ChatModel
OpenAI Chat Model implementation that interacts with the OpenAI API to generate chat completions.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OpenAiChatModel(OpenAiClient client)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.springframework.ai.chat.model.ChatResponse`
  `call(org.springframework.ai.chat.prompt.Prompt prompt)`
  `protected static OpenAiChatCompletionRequest`
  `extractOptions(OpenAiChatCompletionRequest request, org.springframework.ai.chat.prompt.ChatOptions options)`
  Adds options to the request.
  `reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>`
  `stream(org.springframework.ai.chat.prompt.Prompt prompt)`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.springframework.ai.chat.model.ChatModel

  `call, call, getDefaultOptions`

  ### Methods inherited from interface org.springframework.ai.chat.model.StreamingChatModel

  `stream, stream`

- ## Constructor Details

  - ### OpenAiChatModel

    public OpenAiChatModel(OpenAiClient client)

- ## Method Details

  - ### call

    @Nonnull public org.springframework.ai.chat.model.ChatResponse call(@Nonnull org.springframework.ai.chat.prompt.Prompt prompt)
    Specified by:
      `call` in interface `org.springframework.ai.chat.model.ChatModel`
    Specified by:
      `call` in interface `org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>`

  - ### stream

    @Nonnull public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> stream(@Nonnull org.springframework.ai.chat.prompt.Prompt prompt)
    Specified by:
      `stream` in interface `org.springframework.ai.chat.model.ChatModel`
    Specified by:
      `stream` in interface `org.springframework.ai.chat.model.StreamingChatModel`
    Specified by:
      `stream` in interface `org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>`

  - ### extractOptions

    @Nonnull protected static OpenAiChatCompletionRequest extractOptions(@Nonnull OpenAiChatCompletionRequest request, @Nonnull org.springframework.ai.chat.prompt.ChatOptions options)
    Adds options to the request.
    Parameters:
      `request` - the request to modify
      `options` - the options to extract
    Returns:
      the modified request with options applied