Class OpenAiChatOptions

java.lang.Object
org.springframework.ai.openai.OpenAiChatOptions
All Implemented Interfaces:
ChatOptions, ModelOptions, StructuredOutputChatOptions, ToolCallingChatOptions

public class OpenAiChatOptions extends Object implements ToolCallingChatOptions, StructuredOutputChatOptions
Configuration information for the Chat Model implementation using the OpenAI Java SDK.
Author:
Julien Dubois, Christian Tzolov, Thomas Vitale, Mariusz Bernacki, lambochen, Ilayaperumal Gopinathan, Sebastien Deleuze, guan xu
  • Field Details

    • DEFAULT_CHAT_MODEL

      public static final String DEFAULT_CHAT_MODEL
  • Constructor Details

  • Method Details

    • getBaseUrl

      public @Nullable String getBaseUrl()
      Gets the frequency penalty parameter.
      Returns:
      the frequency penalty
    • getApiKey

      public @Nullable String getApiKey()
    • getCredential

      public @Nullable com.openai.credential.Credential getCredential()
    • getModel

      public String getModel()
      Description copied from interface: ChatOptions
      Returns the model to use for the chat.
      Specified by:
      getModel in interface ChatOptions
      Returns:
      the model to use for the chat
    • getMicrosoftDeploymentName

      public @Nullable String getMicrosoftDeploymentName()
    • getDeploymentName

      public @Nullable String getDeploymentName()
      Alias for getAzureDeploymentName()
    • getMicrosoftFoundryServiceVersion

      public @Nullable com.openai.azure.AzureOpenAIServiceVersion getMicrosoftFoundryServiceVersion()
    • getOrganizationId

      public @Nullable String getOrganizationId()
    • isMicrosoftFoundry

      public boolean isMicrosoftFoundry()
    • isGitHubModels

      public boolean isGitHubModels()
    • getTimeout

      public Duration getTimeout()
    • getMaxRetries

      public int getMaxRetries()
    • getProxy

      public @Nullable Proxy getProxy()
    • getCustomHeaders

      public @Nullable Map<String,String> getCustomHeaders()
    • getFrequencyPenalty

      public @Nullable Double getFrequencyPenalty()
      Description copied from interface: ChatOptions
      Returns the frequency penalty to use for the chat.
      Specified by:
      getFrequencyPenalty in interface ChatOptions
      Returns:
      the frequency penalty to use for the chat
    • getLogitBias

      public @Nullable Map<String,Integer> getLogitBias()
      Gets the logit bias map.
      Returns:
      the logit bias map
    • getLogprobs

      public @Nullable Boolean getLogprobs()
      Gets whether to return log probabilities.
      Returns:
      true if log probabilities should be returned
    • getTopLogprobs

      public @Nullable Integer getTopLogprobs()
      Gets the number of top log probabilities to return.
      Returns:
      the number of top log probabilities
    • getMaxTokens

      public @Nullable Integer getMaxTokens()
      Description copied from interface: ChatOptions
      Returns the maximum number of tokens to use for the chat.
      Specified by:
      getMaxTokens in interface ChatOptions
      Returns:
      the maximum number of tokens to use for the chat
    • getMaxCompletionTokens

      public @Nullable Integer getMaxCompletionTokens()
      Gets the maximum number of completion tokens.
      Returns:
      the maximum number of completion tokens
    • getN

      public @Nullable Integer getN()
      Gets the number of completions to generate.
      Returns:
      the number of completions
    • getOutputModalities

      public @Nullable List<String> getOutputModalities()
      Gets the output modalities.
      Returns:
      the output modalities
    • getOutputAudio

      public @Nullable OpenAiChatOptions.AudioParameters getOutputAudio()
      Gets the output audio parameters.
      Returns:
      the output audio parameters
    • getPresencePenalty

      public @Nullable Double getPresencePenalty()
      Description copied from interface: ChatOptions
      Returns the presence penalty to use for the chat.
      Specified by:
      getPresencePenalty in interface ChatOptions
      Returns:
      the presence penalty to use for the chat
    • getResponseFormat

      public @Nullable OpenAiChatModel.ResponseFormat getResponseFormat()
      Gets the response format configuration.
      Returns:
      the response format
    • getStreamOptions

      public @Nullable OpenAiChatOptions.StreamOptions getStreamOptions()
      Gets the stream options.
      Returns:
      the stream options
    • getSeed

      public @Nullable Integer getSeed()
      Gets the random seed for deterministic generation.
      Returns:
      the random seed
    • getStop

      public @Nullable List<String> getStop()
      Gets the stop sequences.
      Returns:
      the list of stop sequences
    • getStopSequences

      public @Nullable List<String> getStopSequences()
      Description copied from interface: ChatOptions
      Returns the stop sequences to use for the chat.
      Specified by:
      getStopSequences in interface ChatOptions
      Returns:
      the stop sequences to use for the chat
    • getTemperature

      public @Nullable Double getTemperature()
      Description copied from interface: ChatOptions
      Returns the temperature to use for the chat.
      Specified by:
      getTemperature in interface ChatOptions
      Returns:
      the temperature to use for the chat
    • getTopP

      public @Nullable Double getTopP()
      Description copied from interface: ChatOptions
      Returns the top P to use for the chat.
      Specified by:
      getTopP in interface ChatOptions
      Returns:
      the top P to use for the chat
    • getToolChoice

      public @Nullable Object getToolChoice()
      Gets the tool choice configuration.
      Returns:
      the tool choice option
    • getUser

      public @Nullable String getUser()
      Gets the user identifier.
      Returns:
      the user identifier
    • getParallelToolCalls

      public @Nullable Boolean getParallelToolCalls()
      Gets whether to enable parallel tool calls.
      Returns:
      true if parallel tool calls are enabled
    • getStore

      public @Nullable Boolean getStore()
      Gets whether to store the conversation.
      Returns:
      true if the conversation should be stored
    • getMetadata

      public @Nullable Map<String,String> getMetadata()
      Gets the metadata map.
      Returns:
      the metadata map
    • getReasoningEffort

      public @Nullable String getReasoningEffort()
      Gets the reasoning effort level.
      Returns:
      the reasoning effort level
    • getVerbosity

      public @Nullable String getVerbosity()
      Gets the verbosity level.
      Returns:
      the verbosity level
    • getServiceTier

      public @Nullable String getServiceTier()
      Gets the service tier.
      Returns:
      the service tier
    • getPromptCacheKey

      public @Nullable String getPromptCacheKey()
      Gets the prompt cache key.
      Returns:
      the prompt cache key
    • getExtraBody

      public @Nullable Map<String,Object> getExtraBody()
    • getToolCallbacks

      public @Nullable List<ToolCallback> getToolCallbacks()
      Description copied from interface: ToolCallingChatOptions
      ToolCallbacks to be registered with the ChatModel.
      Specified by:
      getToolCallbacks in interface ToolCallingChatOptions
    • getToolContext

      public @Nullable Map<String,Object> getToolContext()
      Description copied from interface: ToolCallingChatOptions
      Get the configured tool context.
      Specified by:
      getToolContext in interface ToolCallingChatOptions
      Returns:
      the tool context map.
    • getTopK

      public @Nullable Integer getTopK()
      Description copied from interface: ChatOptions
      Returns the top K to use for the chat.
      Specified by:
      getTopK in interface ChatOptions
      Returns:
      the top K to use for the chat
    • getOutputSchema

      public @Nullable String getOutputSchema()
      Specified by:
      getOutputSchema in interface StructuredOutputChatOptions
    • builder

      public static OpenAiChatOptions.Builder builder()
      Description copied from interface: ToolCallingChatOptions
      A builder to create a new ToolCallingChatOptions instance.
      Returns:
      Returns a new ChatOptions.Builder.
    • mutate

      public OpenAiChatOptions.Builder mutate()
      Description copied from interface: ToolCallingChatOptions
      Returns a new ToolCallingChatOptions.Builder initialized with the values of this ToolCallingChatOptions. Narrows the return type of ChatOptions.mutate() so generic tool calling code can chain methods without casting.
      Specified by:
      mutate in interface ChatOptions
      Specified by:
      mutate in interface StructuredOutputChatOptions
      Specified by:
      mutate in interface ToolCallingChatOptions
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object