anyllm_client 0.2.0

Async HTTP client for Anthropic-to-OpenAI translation with retry, SSRF protection, and SSE streaming
Documentation

anyllm_client

Async HTTP client for Anthropic-to-OpenAI API translation.

Accepts Anthropic Messages API requests, translates them to OpenAI Chat Completions format, sends them to an OpenAI-compatible backend, and translates the response back. Supports non-streaming and streaming (SSE) modes, retry with exponential backoff, SSRF-safe DNS resolution, and mTLS.

Quick start

use anyllm_client::{Client, ClientConfig, Auth};
use anyllm_translate::TranslationConfig;
use anyllm_translate::anthropic::MessageCreateRequest;

# async fn example() -> Result<(), anyllm_client::ClientError> {
let config = ClientConfig::builder()
    .backend_url("https://api.openai.com/v1/chat/completions")
    .auth(Auth::Bearer("sk-...".into()))
    .translation(
        TranslationConfig::builder()
            .model_map("haiku", "gpt-4o-mini")
            .model_map("sonnet", "gpt-4o")
            .build()
    )
    .build();

let client = Client::new(config);

let req: MessageCreateRequest = serde_json::from_str(r#"{
    "model": "claude-sonnet-4-6",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "Hello"}]
}"#).unwrap();

let response = client.messages(&req).await?;
println!("{:?}", response);
# Ok(())
# }

Modules

  • [client] -- High-level Client and [ClientBuilder] for Anthropic-in, Anthropic-out API calls
  • [tools] -- Builder helpers for [Tool] definitions and [ToolChoice]
  • [http] -- HTTP client builder with TLS and SSRF protection
  • [retry] -- Generic retry logic with exponential backoff
  • [rate_limit] -- Rate limit header extraction and format conversion
  • [sse] -- Framework-agnostic SSE frame parser
  • [error] -- Error types