Language model implementation for Anthropic's Messages API.
aisdk::LanguageModelV1 -> AnthropicLanguageModel
new()Initialize the Anthropic language model.
AnthropicLanguageModel$new(model_id, config, capabilities = list())model_idThe model ID (e.g., "claude-sonnet-4-20250514").
configConfiguration list with api_key, base_url, headers, etc.
capabilitiesOptional list of capability flags.
get_config()Get the configuration list.
AnthropicLanguageModel$get_config()A list with provider configuration.
do_generate()Generate text (non-streaming).
AnthropicLanguageModel$do_generate(params)paramsA list of call options including messages, temperature, etc.
A GenerateResult object.
do_stream()Generate text (streaming).
AnthropicLanguageModel$do_stream(params, callback)paramsA list of call options.
callbackA function called for each chunk: callback(text, done).
A GenerateResult object.
format_tool_result()Format a tool execution result for Anthropic's API.
AnthropicLanguageModel$format_tool_result(
tool_call_id,
tool_name,
result_content
)tool_call_idThe ID of the tool call (tool_use_id in Anthropic terms).
tool_nameThe name of the tool (not used by Anthropic but kept for interface consistency).
result_contentThe result content from executing the tool.
A list formatted as a message for Anthropic's API.
get_history_format()Get the message format for Anthropic.
AnthropicLanguageModel$get_history_format()
clone()The objects of this class are cloneable with this method.
AnthropicLanguageModel$clone(deep = FALSE)deepWhether to make a deep clone.