AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:313–459

AnthropicChatModel的构建器。位于 io.agentscope.extensions.model.anthropic 包。核心成员包括 baseUrl、apiKey、authToken、modelName、stream、defaultOptions。

Builder for AnthropicChatModel.

方法摘要Method Summary

方法Method说明Description
public Builder baseUrl(String baseUrl)
设置基类 URL。
Sets the base URL for the Anthropic API.
public Builder apiKey(String apiKey)
设置API 键。
Sets the API key for authentication.
public Builder authToken(String authToken)
设置认证令牌。
Sets the bearer token for authentication with an Anthropic-compatible gateway.
public Builder modelName(String modelName)
设置模型名称。
Sets the model name.
public Builder stream(boolean streamEnabled)
设置流。
Enables or disables streaming.
public Builder defaultOptions(GenerateOptions defaultOptions)
设置默认选项。
Sets default generation options.
public Builder formatter(AnthropicBaseFormatter formatter)
设置自定义格式化器。
Sets a custom formatter.
public Builder proxy(ProxyConfig proxyConfig)
设置代理。
Sets the proxy configuration for HTTP traffic.
public Builder cacheTtl(String cacheTtl)
设置缓存存活时间。
Sets the TTL for prompt-caching markers (e.g.
public Builder contextWindowSize(int contextWindowSize)
设置该配置项。
Performs the context window size operation.
public AnthropicChatModel build()
构建AnthropicChatModel 实例。
Builds the AnthropicChatModel instance.

方法详情Method Detail

baseUrl

public Builder baseUrl(String baseUrl)

设置基类 URL。

Sets the base URL for the Anthropic API.

参数Parameters
名称Name类型Type说明Description
baseUrlString基类 URL。the base URL
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:331–334

apiKey

public Builder apiKey(String apiKey)

设置API 键。

Sets the API key for authentication.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 密钥。the API key
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:342–345

authToken

public Builder authToken(String authToken)

设置认证令牌。

Sets the bearer token for authentication with an Anthropic-compatible gateway.

参数Parameters
名称Name类型Type说明Description
authTokenString认证令牌(类型 `String`)。the token without the `Bearer ` prefix (null to omit)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:356–359

modelName

public Builder modelName(String modelName)

设置模型名称。

Sets the model name.

参数Parameters
名称Name类型Type说明Description
modelNameString模型名称。the model name
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:367–370

stream

public Builder stream(boolean streamEnabled)

设置流。

Enables or disables streaming.

参数Parameters
名称Name类型Type说明Description
streamEnabledboolean流已启用(类型 `boolean`)。true to enable streaming
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:378–381

defaultOptions

public Builder defaultOptions(GenerateOptions defaultOptions)

设置默认选项。

Sets default generation options.

参数Parameters
名称Name类型Type说明Description
defaultOptionsGenerateOptions默认选项。the default options
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:389–392

formatter

public Builder formatter(AnthropicBaseFormatter formatter)

设置自定义格式化器。

Sets a custom formatter.

参数Parameters
名称Name类型Type说明Description
formatterAnthropicBaseFormatter格式化器。the formatter
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:400–403

proxy

public Builder proxy(ProxyConfig proxyConfig)

设置代理。

Sets the proxy configuration for HTTP traffic.

参数Parameters
名称Name类型Type说明Description
proxyConfigProxyConfig代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:415–418

cacheTtl

public Builder cacheTtl(String cacheTtl)

设置缓存存活时间。

Sets the TTL for prompt-caching markers (e.g.

参数Parameters
名称Name类型Type说明Description
cacheTtlString缓存存活时间(类型 `String`)。the cache TTL string (null for default 5m ephemeral)
返回Returns Builder
返回当前实例,以支持链式调用。this builder
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:426–429

contextWindowSize

public Builder contextWindowSize(int contextWindowSize)

设置该配置项。

Performs the context window size operation.

参数Parameters
名称Name类型Type说明Description
contextWindowSizeint上下文 Window 大小(类型 `int`)。The context window size.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:431–434

build

public AnthropicChatModel build()

构建AnthropicChatModel 实例。

Builds the AnthropicChatModel instance.

返回Returns AnthropicChatModel
一种新的AnthropicChatModel。a new AnthropicChatModel
源码Source io/agentscope/extensions/model/anthropic/AnthropicChatModel.java:441–458
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.