Package org.springframework.ai.openai
Class OpenAiChatOptions.Builder
java.lang.Object
org.springframework.ai.openai.OpenAiChatOptions.Builder
- Enclosing class:
- OpenAiChatOptions
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
frequencyPenalty
(Double frequencyPenalty) httpHeaders
(Map<String, String> httpHeaders) internalToolExecutionEnabled
(Boolean internalToolExecutionEnabled) maxCompletionTokens
(Integer maxCompletionTokens) Sets an upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.Sets the maximum number of tokens to generate in the chat completion.model
(OpenAiApi.ChatModel openAiChatModel) outputModalities
(List<String> modalities) parallelToolCalls
(Boolean parallelToolCalls) presencePenalty
(Double presencePenalty) reasoningEffort
(String reasoningEffort) responseFormat
(ResponseFormat responseFormat) streamUsage
(boolean enableStreamUsage) temperature
(Double temperature) toolCallbacks
(List<ToolCallback> toolCallbacks) toolCallbacks
(ToolCallback... toolCallbacks) toolChoice
(Object toolChoice) toolContext
(Map<String, Object> toolContext) tools
(List<OpenAiApi.FunctionTool> tools) topLogprobs
(Integer topLogprobs) webSearchOptions
(OpenAiApi.ChatCompletionRequest.WebSearchOptions webSearchOptions)
-
Field Details
-
options
-
-
Constructor Details
-
Builder
public Builder() -
Builder
-
-
Method Details
-
model
-
model
-
frequencyPenalty
-
logitBias
-
logprobs
-
topLogprobs
-
maxTokens
Sets the maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length.Model-specific usage:
- Use for non-reasoning models (e.g., gpt-4o, gpt-3.5-turbo)
- Cannot be used with reasoning models (e.g., o1, o3, o4-mini series)
Mutual exclusivity: This parameter cannot be used together with
maxCompletionTokens(Integer)
. If both are set, the last one set will be used and the other will be cleared with a warning.- Parameters:
maxTokens
- the maximum number of tokens to generate, or null to unset- Returns:
- this builder instance
-
maxCompletionTokens
Sets an upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.Model-specific usage:
- Required for reasoning models (e.g., o1, o3, o4-mini series)
- Cannot be used with non-reasoning models (e.g., gpt-4o, gpt-3.5-turbo)
Mutual exclusivity: This parameter cannot be used together with
maxTokens(Integer)
. If both are set, the last one set will be used and the other will be cleared with a warning.- Parameters:
maxCompletionTokens
- the maximum number of completion tokens to generate, or null to unset- Returns:
- this builder instance
-
N
-
outputModalities
-
outputAudio
-
presencePenalty
-
responseFormat
-
streamUsage
-
seed
-
stop
-
temperature
-
topP
-
tools
-
toolChoice
-
user
-
parallelToolCalls
-
toolCallbacks
-
toolCallbacks
-
toolNames
-
toolNames
-
internalToolExecutionEnabled
public OpenAiChatOptions.Builder internalToolExecutionEnabled(@Nullable Boolean internalToolExecutionEnabled) -
httpHeaders
-
toolContext
-
store
-
metadata
-
reasoningEffort
-
webSearchOptions
public OpenAiChatOptions.Builder webSearchOptions(OpenAiApi.ChatCompletionRequest.WebSearchOptions webSearchOptions) -
verbosity
-
build
-