Learn R Programming

aisdk (version 1.1.0)

create_aihubmix_anthropic: Create AiHubMix Provider (Anthropic API Format)

Description

Factory function to create an AiHubMix provider using the Anthropic-compatible API. This allows you to use AiHubMix Claude models with the native Anthropic API format, unlocking advanced features like Prompt Caching.

Usage

create_aihubmix_anthropic(
  api_key = NULL,
  extended_caching = FALSE,
  headers = NULL
)

Value

An AnthropicProvider object configured for AiHubMix.

Arguments

api_key

AiHubMix API key. Defaults to AIHUBMIX_API_KEY env var.

extended_caching

Logical. If TRUE, enables the 1-hour beta cache for Claude.

headers

Optional additional headers.

Details

AiHubMix provides an Anthropic-compatible endpoint at https://aihubmix.com/v1. This convenience function wraps create_anthropic() with AiHubMix-specific defaults.

Examples

Run this code
# \donttest{
if (interactive()) {
    # Use AiHubMix via Anthropic API format (unlocks caching)
    aihubmix_claude <- create_aihubmix_anthropic()
    model <- aihubmix_claude$language_model("claude-3-5-sonnet-20241022")
    result <- generate_text(model, "Hello Claude!")
}
# }

Run the code above in your browser using DataLab