Class AnthropicChatOptions

java.lang.Object
org.springframework.ai.anthropic.AbstractAnthropicOptions
org.springframework.ai.anthropic.AnthropicChatOptions
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 AnthropicChatOptions extends AbstractAnthropicOptions implements org.springframework.ai.model.tool.ToolCallingChatOptions, org.springframework.ai.model.tool.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
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

    • AnthropicChatOptions

      public AnthropicChatOptions()
  • Method Details

    • builder

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

      public @Nullable Integer getMaxTokens()
      Specified by:
      getMaxTokens in interface org.springframework.ai.chat.prompt.ChatOptions
    • setMaxTokens

      public void setMaxTokens(@Nullable Integer maxTokens)
    • getMetadata

      public @Nullable com.anthropic.models.messages.Metadata getMetadata()
    • setMetadata

      public void setMetadata(@Nullable com.anthropic.models.messages.Metadata metadata)
    • getStopSequences

      public @Nullable List<String> getStopSequences()
      Specified by:
      getStopSequences in interface org.springframework.ai.chat.prompt.ChatOptions
    • setStopSequences

      public void setStopSequences(@Nullable List<String> stopSequences)
    • getTemperature

      public @Nullable Double getTemperature()
      Specified by:
      getTemperature in interface org.springframework.ai.chat.prompt.ChatOptions
    • setTemperature

      public void setTemperature(@Nullable Double temperature)
    • getTopP

      public @Nullable Double getTopP()
      Specified by:
      getTopP in interface org.springframework.ai.chat.prompt.ChatOptions
    • setTopP

      public void setTopP(@Nullable Double topP)
    • getTopK

      public @Nullable Integer getTopK()
      Specified by:
      getTopK in interface org.springframework.ai.chat.prompt.ChatOptions
    • setTopK

      public void setTopK(@Nullable Integer topK)
    • getToolChoice

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

      public void setToolChoice(@Nullable com.anthropic.models.messages.ToolChoice toolChoice)
    • getThinking

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

      public void setThinking(@Nullable com.anthropic.models.messages.ThinkingConfigParam thinking)
    • getDisableParallelToolUse

      public @Nullable Boolean getDisableParallelToolUse()
    • setDisableParallelToolUse

      public void setDisableParallelToolUse(@Nullable Boolean disableParallelToolUse)
    • getToolCallbacks

      public List<org.springframework.ai.tool.ToolCallback> getToolCallbacks()
      Specified by:
      getToolCallbacks in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • setToolCallbacks

      public void setToolCallbacks(List<org.springframework.ai.tool.ToolCallback> toolCallbacks)
      Specified by:
      setToolCallbacks in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • getToolNames

      public Set<String> getToolNames()
      Specified by:
      getToolNames in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • setToolNames

      public void setToolNames(Set<String> toolNames)
      Specified by:
      setToolNames in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • getInternalToolExecutionEnabled

      public @Nullable Boolean getInternalToolExecutionEnabled()
      Specified by:
      getInternalToolExecutionEnabled in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • setInternalToolExecutionEnabled

      public void setInternalToolExecutionEnabled(@Nullable Boolean internalToolExecutionEnabled)
      Specified by:
      setInternalToolExecutionEnabled in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • getToolContext

      public Map<String,Object> getToolContext()
      Specified by:
      getToolContext in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • setToolContext

      public void setToolContext(Map<String,Object> toolContext)
      Specified by:
      setToolContext in interface org.springframework.ai.model.tool.ToolCallingChatOptions
    • getCitationDocuments

      public List<AnthropicCitationDocument> getCitationDocuments()
    • setCitationDocuments

      public void setCitationDocuments(List<AnthropicCitationDocument> citationDocuments)
    • 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()
    • setCacheOptions

      public void setCacheOptions(AnthropicCacheOptions cacheOptions)
    • getOutputConfig

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

      public void setOutputConfig(@Nullable com.anthropic.models.messages.OutputConfig outputConfig)
    • getHttpHeaders

      public Map<String,String> getHttpHeaders()
    • setHttpHeaders

      public void setHttpHeaders(Map<String,String> httpHeaders)
    • getSkillContainer

      public @Nullable AnthropicSkillContainer getSkillContainer()
    • setSkillContainer

      public void setSkillContainer(@Nullable AnthropicSkillContainer skillContainer)
    • getOutputSchema

      public @Nullable String getOutputSchema()
      Specified by:
      getOutputSchema in interface org.springframework.ai.model.tool.StructuredOutputChatOptions
    • setOutputSchema

      public void setOutputSchema(@Nullable String outputSchema)
      Specified by:
      setOutputSchema in interface org.springframework.ai.model.tool.StructuredOutputChatOptions
    • getFrequencyPenalty

      public @Nullable Double getFrequencyPenalty()
      Specified by:
      getFrequencyPenalty in interface org.springframework.ai.chat.prompt.ChatOptions
    • getPresencePenalty

      public @Nullable Double getPresencePenalty()
      Specified by:
      getPresencePenalty in interface org.springframework.ai.chat.prompt.ChatOptions
    • copy

      public AnthropicChatOptions copy()
      Specified by:
      copy in interface org.springframework.ai.chat.prompt.ChatOptions
    • mutate

      Specified by:
      mutate in interface org.springframework.ai.chat.prompt.ChatOptions
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object