Class AnthropicChatModel.Builder

java.lang.Object
io.agentscope.extensions.model.anthropic.AnthropicChatModel.Builder
Enclosing class:
AnthropicChatModel

public static class AnthropicChatModel.Builder extends Object
Builder for AnthropicChatModel.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • baseUrl

      public AnthropicChatModel.Builder baseUrl(String baseUrl)
      Sets the base URL for the Anthropic API.
      Parameters:
      baseUrl - the base URL
      Returns:
      this builder
    • apiKey

      public AnthropicChatModel.Builder apiKey(String apiKey)
      Sets the API key for authentication.
      Parameters:
      apiKey - the API key
      Returns:
      this builder
    • authToken

      public AnthropicChatModel.Builder authToken(String authToken)
      Sets the bearer token for authentication with an Anthropic-compatible gateway.

      The SDK adds the Bearer prefix to the Authorization header. Configuring both an API key and a bearer token causes model construction to fail.

      Parameters:
      authToken - the token without the Bearer prefix (null to omit)
      Returns:
      this builder
    • modelName

      public AnthropicChatModel.Builder modelName(String modelName)
      Sets the model name.
      Parameters:
      modelName - the model name
      Returns:
      this builder
    • stream

      public AnthropicChatModel.Builder stream(boolean streamEnabled)
      Enables or disables streaming.
      Parameters:
      streamEnabled - true to enable streaming
      Returns:
      this builder
    • defaultOptions

      public AnthropicChatModel.Builder defaultOptions(io.agentscope.core.model.GenerateOptions defaultOptions)
      Sets default generation options.
      Parameters:
      defaultOptions - the default options
      Returns:
      this builder
    • formatter

      public AnthropicChatModel.Builder formatter(AnthropicBaseFormatter formatter)
      Sets a custom formatter.
      Parameters:
      formatter - the formatter
      Returns:
      this builder
    • proxy

      public AnthropicChatModel.Builder proxy(io.agentscope.core.model.transport.ProxyConfig proxyConfig)
      Sets the proxy configuration for HTTP traffic.

      The Anthropic Java SDK does not support proxy authentication or nonProxyHosts. Only ProxyConfig.toJavaProxy() is used; username, password, and nonProxyHosts on ProxyConfig have no effect.

      Parameters:
      proxyConfig - the proxy configuration (see ProxyConfig)
      Returns:
      this builder
    • cacheTtl

      public AnthropicChatModel.Builder cacheTtl(String cacheTtl)
      Sets the TTL for prompt-caching markers (e.g. "1h").
      Parameters:
      cacheTtl - the cache TTL string (null for default 5m ephemeral)
      Returns:
      this builder
    • contextWindowSize

      public AnthropicChatModel.Builder contextWindowSize(int contextWindowSize)
    • build

      public AnthropicChatModel build()
      Builds the AnthropicChatModel instance.
      Returns:
      a new AnthropicChatModel