Package org.springframework.ai.openai
Class OpenAiChatOptions
java.lang.Object
org.springframework.ai.openai.OpenAiChatOptions
- All Implemented Interfaces:
org.springframework.ai.chat.prompt.ChatOptions,org.springframework.ai.model.ModelOptions,org.springframework.ai.model.tool.StructuredOutputChatOptions,org.springframework.ai.model.tool.ToolCallingChatOptions
public class OpenAiChatOptions
extends Object
implements org.springframework.ai.model.tool.ToolCallingChatOptions, org.springframework.ai.model.tool.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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic final recordstatic classstatic final record -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOpenAiChatOptions(@Nullable String baseUrl, @Nullable String apiKey, @Nullable com.openai.credential.Credential credential, @Nullable String model, @Nullable String microsoftDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion microsoftFoundryServiceVersion, @Nullable String organizationId, @Nullable Boolean isMicrosoftFoundry, @Nullable Boolean isGitHubModels, @Nullable Duration timeout, @Nullable Integer maxRetries, @Nullable Proxy proxy, @Nullable Map<String, String> customHeaders, @Nullable Double frequencyPenalty, @Nullable Integer maxTokens, @Nullable Double presencePenalty, @Nullable List<String> stop, @Nullable Double temperature, @Nullable Double topP, @Nullable List<org.springframework.ai.tool.ToolCallback> toolCallbacks, @Nullable Map<String, Object> toolContext, @Nullable Map<String, Integer> logitBias, @Nullable Boolean logprobs, @Nullable Integer topLogprobs, @Nullable Integer maxCompletionTokens, @Nullable Integer n, @Nullable List<String> outputModalities, @Nullable OpenAiChatOptions.AudioParameters outputAudio, @Nullable OpenAiChatModel.ResponseFormat responseFormat, @Nullable OpenAiChatOptions.StreamOptions streamOptions, @Nullable Integer seed, @Nullable Object toolChoice, @Nullable String user, @Nullable Boolean parallelToolCalls, @Nullable Boolean store, @Nullable Boolean strict, @Nullable Map<String, String> metadata, @Nullable String reasoningEffort, @Nullable String verbosity, @Nullable String serviceTier, @Nullable String promptCacheKey, @Nullable Map<String, Object> extraBody) -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiChatOptions.Builderbuilder()boolean@Nullable String@Nullable StringGets the frequency penalty parameter.@Nullable com.openai.credential.Credential@Nullable StringAlias for getAzureDeploymentName()@Nullable DoubleGets the logit bias map.@Nullable BooleanGets whether to return log probabilities.@Nullable IntegerGets the maximum number of completion tokens.int@Nullable IntegerGets the metadata map.@Nullable String@Nullable com.openai.azure.AzureOpenAIServiceVersiongetModel()@Nullable IntegergetN()Gets the number of completions to generate.@Nullable String@Nullable OpenAiChatOptions.AudioParametersGets the output audio parameters.Gets the output modalities.@Nullable String@Nullable BooleanGets whether to enable parallel tool calls.@Nullable Double@Nullable StringGets the prompt cache key.@Nullable ProxygetProxy()@Nullable StringGets the reasoning effort level.@Nullable OpenAiChatModel.ResponseFormatGets the response format configuration.@Nullable IntegergetSeed()Gets the random seed for deterministic generation.@Nullable StringGets the service tier.getStop()Gets the stop sequences.@Nullable BooleangetStore()Gets whether to store the conversation.@Nullable OpenAiChatOptions.StreamOptionsGets the stream options.@Nullable BooleanGets whether OpenAI Tool/Function calling strict mode is enabled.@Nullable Double@Nullable List<org.springframework.ai.tool.ToolCallback>@Nullable ObjectGets the tool choice configuration.@Nullable IntegergetTopK()@Nullable IntegerGets the number of top log probabilities to return.@Nullable DoublegetTopP()@Nullable StringgetUser()Gets the user identifier.@Nullable StringGets the verbosity level.inthashCode()booleanbooleanmutate()
-
Field Details
-
DEFAULT_CHAT_MODEL
-
-
Constructor Details
-
OpenAiChatOptions
protected OpenAiChatOptions(@Nullable String baseUrl, @Nullable String apiKey, @Nullable com.openai.credential.Credential credential, @Nullable String model, @Nullable String microsoftDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion microsoftFoundryServiceVersion, @Nullable String organizationId, @Nullable Boolean isMicrosoftFoundry, @Nullable Boolean isGitHubModels, @Nullable Duration timeout, @Nullable Integer maxRetries, @Nullable Proxy proxy, @Nullable Map<String, String> customHeaders, @Nullable Double frequencyPenalty, @Nullable Integer maxTokens, @Nullable Double presencePenalty, @Nullable List<String> stop, @Nullable Double temperature, @Nullable Double topP, @Nullable List<org.springframework.ai.tool.ToolCallback> toolCallbacks, @Nullable Map<String, Object> toolContext, @Nullable Map<String, Integer> logitBias, @Nullable Boolean logprobs, @Nullable Integer topLogprobs, @Nullable Integer maxCompletionTokens, @Nullable Integer n, @Nullable List<String> outputModalities, @Nullable OpenAiChatOptions.AudioParameters outputAudio, @Nullable OpenAiChatModel.ResponseFormat responseFormat, @Nullable OpenAiChatOptions.StreamOptions streamOptions, @Nullable Integer seed, @Nullable Object toolChoice, @Nullable String user, @Nullable Boolean parallelToolCalls, @Nullable Boolean store, @Nullable Boolean strict, @Nullable Map<String, String> metadata, @Nullable String reasoningEffort, @Nullable String verbosity, @Nullable String serviceTier, @Nullable String promptCacheKey, @Nullable Map<String, Object> extraBody)
-
-
Method Details
-
getBaseUrl
Gets the frequency penalty parameter.- Returns:
- the frequency penalty
-
getApiKey
-
getCredential
public @Nullable com.openai.credential.Credential getCredential() -
getModel
- Specified by:
getModelin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getMicrosoftDeploymentName
-
getDeploymentName
Alias for getAzureDeploymentName() -
getMicrosoftFoundryServiceVersion
public @Nullable com.openai.azure.AzureOpenAIServiceVersion getMicrosoftFoundryServiceVersion() -
getOrganizationId
-
isMicrosoftFoundry
public boolean isMicrosoftFoundry() -
isGitHubModels
public boolean isGitHubModels() -
getTimeout
-
getMaxRetries
public int getMaxRetries() -
getProxy
-
getCustomHeaders
-
getFrequencyPenalty
- Specified by:
getFrequencyPenaltyin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getLogitBias
Gets the logit bias map.- Returns:
- the logit bias map
-
getLogprobs
Gets whether to return log probabilities.- Returns:
- true if log probabilities should be returned
-
getTopLogprobs
Gets the number of top log probabilities to return.- Returns:
- the number of top log probabilities
-
getMaxTokens
- Specified by:
getMaxTokensin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getMaxCompletionTokens
Gets the maximum number of completion tokens.- Returns:
- the maximum number of completion tokens
-
getN
Gets the number of completions to generate.- Returns:
- the number of completions
-
getOutputModalities
Gets the output modalities.- Returns:
- the output modalities
-
getOutputAudio
Gets the output audio parameters.- Returns:
- the output audio parameters
-
getPresencePenalty
- Specified by:
getPresencePenaltyin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getResponseFormat
Gets the response format configuration.- Returns:
- the response format
-
getStreamOptions
Gets the stream options.- Returns:
- the stream options
-
getSeed
Gets the random seed for deterministic generation.- Returns:
- the random seed
-
getStop
Gets the stop sequences.- Returns:
- the list of stop sequences
-
getStopSequences
- Specified by:
getStopSequencesin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getTemperature
- Specified by:
getTemperaturein interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getTopP
- Specified by:
getTopPin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getToolChoice
Gets the tool choice configuration.- Returns:
- the tool choice option
-
getUser
Gets the user identifier.- Returns:
- the user identifier
-
getParallelToolCalls
Gets whether to enable parallel tool calls.- Returns:
- true if parallel tool calls are enabled
-
getStore
Gets whether to store the conversation.- Returns:
- true if the conversation should be stored
-
getStrict
Gets whether OpenAI Tool/Function calling strict mode is enabled.This is distinct from
OpenAiChatModel.ResponseFormat.Builder.strict(Boolean), which controls strict schema adherence for JSON schema response format.- Returns:
- true if strict mode is explicitly enabled
-
getMetadata
Gets the metadata map.- Returns:
- the metadata map
-
getReasoningEffort
Gets the reasoning effort level.- Returns:
- the reasoning effort level
-
getVerbosity
Gets the verbosity level.- Returns:
- the verbosity level
-
getServiceTier
Gets the service tier.- Returns:
- the service tier
-
getPromptCacheKey
Gets the prompt cache key.- Returns:
- the prompt cache key
-
getExtraBody
-
getToolCallbacks
- Specified by:
getToolCallbacksin interfaceorg.springframework.ai.model.tool.ToolCallingChatOptions
-
getToolContext
- Specified by:
getToolContextin interfaceorg.springframework.ai.model.tool.ToolCallingChatOptions
-
getTopK
- Specified by:
getTopKin interfaceorg.springframework.ai.chat.prompt.ChatOptions
-
getOutputSchema
- Specified by:
getOutputSchemain interfaceorg.springframework.ai.model.tool.StructuredOutputChatOptions
-
builder
-
mutate
- Specified by:
mutatein interfaceorg.springframework.ai.chat.prompt.ChatOptions- Specified by:
mutatein interfaceorg.springframework.ai.model.tool.StructuredOutputChatOptions- Specified by:
mutatein interfaceorg.springframework.ai.model.tool.ToolCallingChatOptions
-
equals
-
hashCode
public int hashCode()
-