llmkit-rs 0.1.0

Unified multi-provider async LLM client for Rust — OpenAI, Anthropic, Ollama, with Tower middleware
Documentation
//! Same request sent to OpenAI and Anthropic.
//! Run with both `OPENAI_API_KEY` and `ANTHROPIC_API_KEY` set.

use llmkit::prelude::*;

#[tokio::main]
async fn main() -> LlmResult<()> {
    let prompt = "Name one famous Rustacean.";

    let openai = LlmClientBuilder::new()
        .provider(OpenAiProvider::from_env()?.model("gpt-4o-mini"))
        .build()?;

    let anthropic = LlmClientBuilder::new()
        .provider(AnthropicProvider::from_env()?.model("claude-opus-4-8"))
        .build()?;

    for client in [&openai, &anthropic] {
        let resp = client
            .chat_once(ChatRequest::builder().user(prompt).build())
            .await?;
        println!("[{}] {}", resp.provider, resp.text().unwrap_or_default());
    }
    Ok(())
}