A specialized AgentDriver for the Anthropic Messages API, providing
access to the Claude family of models.
Details
Setup: To use this driver, you must set the ANTHROPIC_API_KEY
environment variable. It is recommended to add this to your .Renviron file:
ANTHROPIC_API_KEY="sk-ant-..."
Super class
HydraR::AgentDriver -> AnthropicAPIDriver
Methods
Method new()
Initialize AnthropicAPIDriver
Usage
AnthropicAPIDriver$new(
id = "anthropic_api",
model = "claude-sonnet-4-6",
validation_mode = "warning",
working_dir = NULL
)Method call()
Usage
AnthropicAPIDriver$call(
prompt,
model = NULL,
system_prompt = NULL,
cli_opts = list(),
...
)Examples
if (FALSE) { # \dontrun{
# 1. Initialize the Claude Messages API driver
driver <- AnthropicAPIDriver$new(model = "claude-3-opus-20240229")
# 2. Perform a research task with reasoning constraints
response <- driver$call(
prompt = "Summarize the differences between S3 and R6 classes in R.",
system_prompt = "You are a technical documentarian. Use markdown tables.",
cli_opts = list(
temperature = 0.2,
max_tokens = 1024,
stop_sequences = list("### Conclusion")
)
)
message(response)
} # }