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:
  • Field Details

    • DEFAULT_MODEL

      public static final String DEFAULT_MODEL
      Default model to use for chat completions.
    • DEFAULT_MAX_TOKENS

      public static final Integer DEFAULT_MAX_TOKENS
      Default max tokens for chat completions.
  • Constructor Details

  • Method Details

    • builder

      public static AnthropicChatOptions.Builder builder()
      Creates a new builder for AnthropicChatOptions.
      Returns:
      a new builder instance
    • getBaseUrl

      public @Nullable String getBaseUrl()
    • getApiKey

      public @Nullable String getApiKey()
    • 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
    • getTimeout

      public @Nullable Duration getTimeout()
    • getMaxRetries

      public @Nullable Integer getMaxRetries()
    • getProxy

      public @Nullable Proxy getProxy()
    • getCustomHeaders

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

      public 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
    • getMetadata

      public @Nullable com.anthropic.models.messages.Metadata getMetadata()
    • 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
    • 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
    • getToolChoice

      public @Nullable com.anthropic.models.messages.ToolChoice getToolChoice()
    • getThinking

      public @Nullable com.anthropic.models.messages.ThinkingConfigParam getThinking()
    • getDisableParallelToolUse

      public @Nullable Boolean getDisableParallelToolUse()
    • 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.
    • getCitationDocuments

      public @Nullable List<AnthropicCitationDocument> 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

      public AnthropicCacheOptions getCacheOptions()
    • getOutputConfig

      public @Nullable com.anthropic.models.messages.OutputConfig getOutputConfig()
    • getHttpHeaders

      public @Nullable Map<String,String> getHttpHeaders()
    • getSkillContainer

      public @Nullable AnthropicSkillContainer getSkillContainer()
    • getInferenceGeo

      public @Nullable String getInferenceGeo()
    • getWebSearchTool

      public @Nullable AnthropicWebSearchTool getWebSearchTool()
    • getServiceTier

      public @Nullable AnthropicServiceTier getServiceTier()
    • getOutputSchema

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