Learn R Programming

aisdk (version 1.1.0)

create_anthropic: Create Anthropic Provider

Description

Factory function to create an Anthropic provider.

Usage

create_anthropic(
  api_key = NULL,
  base_url = NULL,
  api_version = NULL,
  headers = NULL,
  name = NULL
)

Value

An AnthropicProvider object.

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.

Examples

Run this code
# \donttest{
if (interactive()) {
  anthropic <- create_anthropic(api_key = "sk-ant-...")
  model <- anthropic$language_model("claude-sonnet-4-20250514")
}
# }

Run the code above in your browser using DataLab