Class OpenAiResponsesChatOptions

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

public class OpenAiResponsesChatOptions extends Object implements ToolCallingChatOptions, StructuredOutputChatOptions
Configuration for OpenAiResponsesChatModel.

Deliberately absent: previousResponseId, conversationId, background and any other knob for a deferred feature. Adding options later is additive; removing them is not. In particular there is no way to ask OpenAI to remember the conversation - this model always sends the whole prompt.

store is absent for the same reason, even though the API accepts it: the model always sends store: false, because a stored response keeps its reasoning at OpenAI instead of returning it, and replaying that reasoning is what makes stateless mode correct. See ResponsesRequestBuilder.

Portable ChatOptions the Responses API has no equivalent for - stop sequences, frequency and presence penalties, topK - return null and are warned about once per option.

Since:
2.1.0
Author:
Dimitar Proynov
  • Field Details

    • DEFAULT_CHAT_MODEL

      public static final String DEFAULT_CHAT_MODEL
  • Constructor Details

  • Method Details

    • builder

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

      public @Nullable String getBaseUrl()
    • 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()
    • getMicrosoftFoundryServiceVersion

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

      public @Nullable String getOrganizationId()
    • isMicrosoftFoundry

      public boolean isMicrosoftFoundry()
    • getTimeout

      public @Nullable Duration getTimeout()
      Return the request timeout, or null to inherit the timeout configured on the OpenAI client.
    • getMaxRetries

      public int getMaxRetries()
    • getProxy

      public @Nullable Proxy getProxy()
    • getCustomHeaders

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

      public @Nullable Integer getMaxOutputTokens()
      Maximum number of tokens the model may generate, max_output_tokens on the wire. Same value as getMaxTokens().
    • 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
    • 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
    • getReasoningEffort

      public @Nullable String getReasoningEffort()
      How hard the model should think: none, minimal, low, medium, high, ... Kept as a String because the accepted values move faster than releases.
    • getReasoningSummary

      public @Nullable String getReasoningSummary()
      Whether and how to summarize the model's reasoning: auto, concise or detailed. Summaries surface under OpenAiResponsesMetadata.REASONING_CONTENT; raw reasoning text is never returned by OpenAI.
    • getVerbosity

      public @Nullable String getVerbosity()
      How verbose the answer should be: low, medium or high.
    • getResponseFormat

      public @Nullable OpenAiChatModel.ResponseFormat getResponseFormat()
    • getStrict

      public @Nullable Boolean getStrict()
      Whether tool schemas are sent as strict.

      When unset, this model sends strict=false explicitly: the Responses API otherwise attempts strict mode, and Spring AI's generated schemas are frequently not strict-compatible, which would make the same tool behave differently across the two OpenAI models.

    • getToolChoice

      public @Nullable Object getToolChoice()
      auto, none, required, a function name as {"type":"function","name":"..."}, or a hosted tool type as {"type":"web_search"}.
    • getParallelToolCalls

      public @Nullable Boolean getParallelToolCalls()
    • getMaxToolCalls

      public @Nullable Integer getMaxToolCalls()
    • getHostedTools

      public @Nullable List<HostedTool> getHostedTools()
      Tools OpenAI runs server-side within the request.
    • getInclude

      public @Nullable List<String> getInclude()
      Extra fields to include in the response, e.g. web_search_call.results. reasoning.encrypted_content is always added by the model, because stateless reasoning is impossible without it.
    • getTruncation

      public @Nullable String getTruncation()
      auto to let OpenAI drop middle-of-conversation items when the context window overflows, or disabled to fail instead.
    • getServiceTier

      public @Nullable String getServiceTier()
    • getPromptCacheKey

      public @Nullable String getPromptCacheKey()
    • getSafetyIdentifier

      public @Nullable String getSafetyIdentifier()
    • getMetadata

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

      public @Nullable Map<String,Object> getExtraBody()
      Extra request body properties, for OpenAI-compatible providers and for API fields that are not modelled here.
    • 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.
    • getOutputSchema

      public @Nullable String getOutputSchema()
      Specified by:
      getOutputSchema in interface StructuredOutputChatOptions
    • 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
    • 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
    • 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
    • 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
    • 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