Package org.springframework.ai.anthropic
Class AnthropicChatOptions
java.lang.Object
org.springframework.ai.anthropic.AnthropicChatOptions
- All Implemented Interfaces:
ChatOptions,ModelOptions,StructuredOutputChatOptions,ToolCallingChatOptions
public class AnthropicChatOptions
extends Object
implements ToolCallingChatOptions, StructuredOutputChatOptions
Chat options for
AnthropicChatModel. Supports model selection, sampling
parameters (temperature, topP, topK), output control (maxTokens, stopSequences), and
tool calling configuration.
Options can be set as defaults during model construction or overridden per-request via
the Prompt.
- Since:
- 1.0.0
- Author:
- Christian Tzolov, Thomas Vitale, Alexandros Pappas, Ilayaperumal Gopinathan, Soby Chacko, Austin Dase, Sebastien Deleuze
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic classBuilder for creatingAnthropicChatOptionsinstances. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAnthropicChatOptions(@Nullable String baseUrl, @Nullable String apiKey, @Nullable String model, @Nullable Duration timeout, @Nullable Integer maxRetries, @Nullable Proxy proxy, @Nullable Map<String, String> customHeaders, @Nullable Integer maxTokens, @Nullable com.anthropic.models.messages.Metadata metadata, @Nullable List<String> stopSequences, @Nullable Double temperature, @Nullable Double topP, @Nullable Integer topK, @Nullable com.anthropic.models.messages.ToolChoice toolChoice, @Nullable com.anthropic.models.messages.ThinkingConfigParam thinking, @Nullable Boolean disableParallelToolUse, @Nullable List<ToolCallback> toolCallbacks, @Nullable Map<String, Object> toolContext, @Nullable List<AnthropicCitationDocument> citationDocuments, @Nullable AnthropicCacheOptions cacheOptions, @Nullable com.anthropic.models.messages.OutputConfig outputConfig, @Nullable Map<String, String> httpHeaders, @Nullable AnthropicSkillContainer skillContainer, @Nullable String inferenceGeo, @Nullable AnthropicWebSearchTool webSearchTool, @Nullable AnthropicServiceTier serviceTier) -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicChatOptions.Builderbuilder()Creates a new builder for AnthropicChatOptions.boolean@Nullable String@Nullable String@Nullable List<AnthropicCitationDocument>@Nullable Boolean@Nullable DoubleReturns the frequency penalty to use for the chat.@Nullable String@Nullable IntegerReturns the maximum number of tokens to use for the chat.@Nullable com.anthropic.models.messages.MetadatagetModel()Returns the model to use for the chat.@Nullable com.anthropic.models.messages.OutputConfig@Nullable String@Nullable DoubleReturns the presence penalty to use for the chat.@Nullable ProxygetProxy()@Nullable AnthropicServiceTier@Nullable AnthropicSkillContainerReturns the stop sequences to use for the chat.@Nullable DoubleReturns the temperature to use for the chat.@Nullable com.anthropic.models.messages.ThinkingConfigParam@Nullable Duration@Nullable List<ToolCallback>ToolCallbacks to be registered with the ChatModel.@Nullable com.anthropic.models.messages.ToolChoiceGet the configured tool context.@Nullable IntegergetTopK()Returns the top K to use for the chat.@Nullable DoublegetTopP()Returns the top P to use for the chat.@Nullable AnthropicWebSearchToolinthashCode()mutate()Returns a newToolCallingChatOptions.Builderinitialized with the values of thisToolCallingChatOptions.voidValidate that all citation documents have consistent citation settings.
-
Field Details
-
DEFAULT_MODEL
Default model to use for chat completions. -
DEFAULT_MAX_TOKENS
Default max tokens for chat completions.
-
-
Constructor Details
-
AnthropicChatOptions
protected AnthropicChatOptions(@Nullable String baseUrl, @Nullable String apiKey, @Nullable String model, @Nullable Duration timeout, @Nullable Integer maxRetries, @Nullable Proxy proxy, @Nullable Map<String, String> customHeaders, @Nullable Integer maxTokens, @Nullable com.anthropic.models.messages.Metadata metadata, @Nullable List<String> stopSequences, @Nullable Double temperature, @Nullable Double topP, @Nullable Integer topK, @Nullable com.anthropic.models.messages.ToolChoice toolChoice, @Nullable com.anthropic.models.messages.ThinkingConfigParam thinking, @Nullable Boolean disableParallelToolUse, @Nullable List<ToolCallback> toolCallbacks, @Nullable Map<String, Object> toolContext, @Nullable List<AnthropicCitationDocument> citationDocuments, @Nullable AnthropicCacheOptions cacheOptions, @Nullable com.anthropic.models.messages.OutputConfig outputConfig, @Nullable Map<String, String> httpHeaders, @Nullable AnthropicSkillContainer skillContainer, @Nullable String inferenceGeo, @Nullable AnthropicWebSearchTool webSearchTool, @Nullable AnthropicServiceTier serviceTier)
-
-
Method Details
-
builder
Creates a new builder for AnthropicChatOptions.- Returns:
- a new builder instance
-
getBaseUrl
-
getApiKey
-
getModel
Description copied from interface:ChatOptionsReturns the model to use for the chat.- Specified by:
getModelin interfaceChatOptions- Returns:
- the model to use for the chat
-
getTimeout
-
getMaxRetries
-
getProxy
-
getCustomHeaders
-
getMaxTokens
Description copied from interface:ChatOptionsReturns the maximum number of tokens to use for the chat.- Specified by:
getMaxTokensin interfaceChatOptions- Returns:
- the maximum number of tokens to use for the chat
-
getMetadata
public @Nullable com.anthropic.models.messages.Metadata getMetadata() -
getStopSequences
Description copied from interface:ChatOptionsReturns the stop sequences to use for the chat.- Specified by:
getStopSequencesin interfaceChatOptions- Returns:
- the stop sequences to use for the chat
-
getTemperature
Description copied from interface:ChatOptionsReturns the temperature to use for the chat.- Specified by:
getTemperaturein interfaceChatOptions- Returns:
- the temperature to use for the chat
-
getTopP
Description copied from interface:ChatOptionsReturns the top P to use for the chat.- Specified by:
getTopPin interfaceChatOptions- Returns:
- the top P to use for the chat
-
getTopK
Description copied from interface:ChatOptionsReturns the top K to use for the chat.- Specified by:
getTopKin interfaceChatOptions- Returns:
- the top K to use for the chat
-
getToolChoice
public @Nullable com.anthropic.models.messages.ToolChoice getToolChoice() -
getThinking
public @Nullable com.anthropic.models.messages.ThinkingConfigParam getThinking() -
getDisableParallelToolUse
-
getToolCallbacks
Description copied from interface:ToolCallingChatOptionsToolCallbacks to be registered with the ChatModel.- Specified by:
getToolCallbacksin interfaceToolCallingChatOptions
-
getToolContext
Description copied from interface:ToolCallingChatOptionsGet the configured tool context.- Specified by:
getToolContextin interfaceToolCallingChatOptions- Returns:
- the tool context map.
-
getCitationDocuments
-
validateCitationConsistency
public void validateCitationConsistency()Validate that all citation documents have consistent citation settings. Anthropic requires all documents to have citations enabled if any do. -
getCacheOptions
-
getOutputConfig
public @Nullable com.anthropic.models.messages.OutputConfig getOutputConfig() -
getHttpHeaders
-
getSkillContainer
-
getInferenceGeo
-
getWebSearchTool
-
getServiceTier
-
getOutputSchema
- Specified by:
getOutputSchemain interfaceStructuredOutputChatOptions
-
getFrequencyPenalty
Description copied from interface:ChatOptionsReturns the frequency penalty to use for the chat.- Specified by:
getFrequencyPenaltyin interfaceChatOptions- Returns:
- the frequency penalty to use for the chat
-
getPresencePenalty
Description copied from interface:ChatOptionsReturns the presence penalty to use for the chat.- Specified by:
getPresencePenaltyin interfaceChatOptions- Returns:
- the presence penalty to use for the chat
-
mutate
Description copied from interface:ToolCallingChatOptionsReturns a newToolCallingChatOptions.Builderinitialized with the values of thisToolCallingChatOptions. Narrows the return type ofChatOptions.mutate()so generic tool calling code can chain methods without casting.- Specified by:
mutatein interfaceChatOptions- Specified by:
mutatein interfaceStructuredOutputChatOptions- Specified by:
mutatein interfaceToolCallingChatOptions
-
equals
-
hashCode
public int hashCode()
-