Skip to contents

Create a Anthropic LLM Object

Usage

create_Anthropic(
  model_name,
  system_prompt = SYSTEM_PROMPT_DEFAULT,
  temperature = TEMPERATURE_DEFAULT,
  output_schema = NULL,
  name = NULL,
  base_url = ANTHROPIC_URL_DEFAULT,
  api_key = NULL,
  api_key_env = ANTHROPIC_API_KEY_ENV_DEFAULT,
  keychain_service = NULL,
  anthropic_version = ANTHROPIC_API_VERSION_DEFAULT,
  anthropic_beta = NULL,
  max_tokens = ANTHROPIC_MAX_TOKENS_DEFAULT,
  timeout = ANTHROPIC_TIMEOUT_DEFAULT,
  extra_headers = NULL,
  extra_body = NULL,
  thinking_budget_tokens = NULL,
  validate_model = FALSE
)

Arguments

model_name

Character: The name of the Anthropic model to use.

system_prompt

Character: The system prompt to use.

temperature

Numeric [0, 2]: The temperature for the model.

output_schema

Optional Schema: Output schema created using schema. Structured output is implemented by forcing a single synthetic tool call whose input_schema is this schema.

name

Optional character: Name for the LLM object.

base_url

Character: Base URL of the Anthropic API.

api_key

Optional character: API key.

api_key_env

Character: Environment variable containing the API key.

keychain_service

Optional character: macOS Keychain service containing the API key.

anthropic_version

Character: Value of the required anthropic-version header.

anthropic_beta

Optional character: Value(s) for the anthropic-beta header.

max_tokens

Integer [1, Inf): Maximum number of tokens the model may generate.

timeout

Numeric (0, Inf): Request timeout in seconds.

extra_headers

Optional list: Additional HTTP headers.

extra_body

Optional list: Additional request body fields.

thinking_budget_tokens

Optional integer [1024, Inf): Extended-thinking budget.

validate_model

Logical: Whether to validate model availability using /models.

Value

Anthropic LLM object

Author

EDG

Examples

llm <- create_Anthropic(
   model_name = "claude-sonnet-4-6",
   system_prompt = "You are a meticulous research assistant.",
   api_key = "test-key",
   validate_model = FALSE
)