Skip to main content
agentscope-extensions-model-anthropic integrates Anthropic Claude models, including Anthropic-specific formatter and request DTO support.

Add the dependency

ModelRegistry

Set ANTHROPIC_API_KEY, then use the anthropic:<model> id:

Explicit builder

Use the builder when you need a custom endpoint, formatter, transport, prompt caching, thinking, or generation options:

Server-side tools

Anthropic built-in tools run on Anthropic’s infrastructure instead of the local AgentScope toolkit. Build a strongly typed SDK tool definition, then wrap the resulting ToolUnion with AnthropicServerTool.of(...):
Server tools can be combined with local function tools. Anthropic selects tools by name, so a name collision fails fast. AnthropicServerTool.of(...) accepts SDK built-in tools only, not custom client tools.

Bearer token authentication

For an Anthropic-compatible gateway that requires Authorization: Bearer <token>, set authToken on the model builder:
Pass the token without the Bearer prefix; the SDK adds it. apiKey sets X-Api-Key, while authToken sets Authorization. Configure only one: setting both causes model construction to fail with an IllegalArgumentException. Configure authentication through the builder rather than GenerateOptions.additionalHeaders, because the SDK owns these authentication headers.

Spring Boot

Spring Boot applications can use the Anthropic starter:
To use a gateway with bearer token authentication:
agentscope.anthropic.auth-token is optional. An unset or blank value leaves bearer authentication disabled. Existing agentscope.anthropic.api-key configuration remains supported, but configuring both nonblank credentials causes startup to fail. Builder customizers run before validation and can clear a credential with apiKey(null) or authToken(null). Full builder options, formatters, credentials, and registry context details are covered in Model.