use multi_llm::{
unwrap_response, AnthropicConfig, DefaultLLMParams, LLMConfig, LlmProvider, UnifiedLLMClient,
UnifiedLLMRequest, UnifiedMessage,
};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let api_key = std::env::var("ANTHROPIC_API_KEY")
.expect("ANTHROPIC_API_KEY environment variable must be set");
let config = LLMConfig {
provider: Box::new(AnthropicConfig {
api_key: Some(api_key),
base_url: "https://api.anthropic.com".to_string(),
default_model: "claude-sonnet-4-20250514".to_string(), max_context_tokens: 200_000,
retry_policy: Default::default(),
enable_prompt_caching: false, cache_ttl: "5m".to_string(),
}),
default_params: DefaultLLMParams::default(),
};
let client = UnifiedLLMClient::from_config(config)?;
let request = UnifiedLLMRequest::new(vec![
UnifiedMessage::system("You are a helpful assistant. Be concise."),
UnifiedMessage::user("What is the capital of France? Answer in one sentence."),
]);
println!("Sending request to Anthropic...");
let response = unwrap_response!(client.execute_llm(request, None, None).await?);
println!("\nResponse: {}", response.content);
if let Some(usage) = &response.usage {
println!(
"\nToken usage: {} input + {} output = {} total",
usage.prompt_tokens, usage.completion_tokens, usage.total_tokens
);
}
Ok(())
}