Class AnthropicChatModel.Builder
java.lang.Object
io.agentscope.extensions.model.anthropic.AnthropicChatModel.Builder
- Enclosing class:
- AnthropicChatModel
Builder for AnthropicChatModel.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the API key for authentication.Sets the bearer token for authentication with an Anthropic-compatible gateway.Sets the base URL for the Anthropic API.build()Builds the AnthropicChatModel instance.Sets the TTL for prompt-caching markers (e.g.contextWindowSize(int contextWindowSize) defaultOptions(io.agentscope.core.model.GenerateOptions defaultOptions) Sets default generation options.formatter(AnthropicBaseFormatter formatter) Sets a custom formatter.Sets the model name.proxy(io.agentscope.core.model.transport.ProxyConfig proxyConfig) Sets the proxy configuration for HTTP traffic.stream(boolean streamEnabled) Enables or disables streaming.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
baseUrl
Sets the base URL for the Anthropic API.- Parameters:
baseUrl- the base URL- Returns:
- this builder
-
apiKey
Sets the API key for authentication.- Parameters:
apiKey- the API key- Returns:
- this builder
-
authToken
Sets the bearer token for authentication with an Anthropic-compatible gateway.The SDK adds the
Bearerprefix to theAuthorizationheader. Configuring both an API key and a bearer token causes model construction to fail.- Parameters:
authToken- the token without theBearerprefix (null to omit)- Returns:
- this builder
-
modelName
Sets the model name.- Parameters:
modelName- the model name- Returns:
- this builder
-
stream
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
Sets a custom formatter.- Parameters:
formatter- the formatter- Returns:
- this builder
-
proxy
Sets the proxy configuration for HTTP traffic.The Anthropic Java SDK does not support proxy authentication or
nonProxyHosts. OnlyProxyConfig.toJavaProxy()is used;username,password, andnonProxyHostsonProxyConfighave no effect.- Parameters:
proxyConfig- the proxy configuration (seeProxyConfig)- Returns:
- this builder
-
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
-
build
Builds the AnthropicChatModel instance.- Returns:
- a new AnthropicChatModel
-