AnthropicProvider: Anthropic Provider Class

AnthropicProviderR Documentation

Anthropic Provider Class

Description

Provider class for Anthropic. Can create language models.

Public fields

specification_version

Provider spec version.

Methods

Public methods


Method new()

Initialize the Anthropic provider.

Usage
AnthropicProvider$new(
  api_key = NULL,
  base_url = NULL,
  api_version = NULL,
  headers = NULL,
  name = NULL,
  timeout_seconds = NULL,
  total_timeout_seconds = NULL,
  first_byte_timeout_seconds = NULL,
  connect_timeout_seconds = NULL,
  idle_timeout_seconds = NULL
)
Arguments
api_key

Anthropic API key. Defaults to ANTHROPIC_API_KEY env var.

base_url

Base URL for API calls. Defaults to https://api.anthropic.com/v1.

api_version

Anthropic API version header. Defaults to "2023-06-01".

headers

Optional additional headers.

name

Optional provider name override.

timeout_seconds

Legacy alias for total_timeout_seconds.

total_timeout_seconds

Optional total request timeout in seconds for API calls.

first_byte_timeout_seconds

Optional time-to-first-byte timeout in seconds for API calls.

connect_timeout_seconds

Optional connection-establishment timeout in seconds for API calls.

idle_timeout_seconds

Optional stall timeout in seconds for API calls.


Method enable_caching()

Enable or disable prompt caching.

Usage
AnthropicProvider$enable_caching(enable = TRUE)
Arguments
enable

Logical.


Method language_model()

Create a language model.

Usage
AnthropicProvider$language_model(model_id = "claude-sonnet-4-20250514")
Arguments
model_id

The model ID (e.g., "claude-sonnet-4-20250514", "claude-3-5-sonnet-20241022").

Returns

An AnthropicLanguageModel object.


Method clone()

The objects of this class are cloneable with this method.

Usage
AnthropicProvider$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


aisdk documentation built on May 29, 2026, 9:07 a.m.