1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # 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
//!
//! ```rust,no_run
//! 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
pub
// Convenience re-exports
pub use ;
pub use ClientError;
pub use ;
pub use RateLimitHeaders;
pub use ;
pub use ;
pub use ;
// Re-export key types from the translator crate so downstream users
// do not need a direct dependency on `anyllm_translate`.
pub use StreamEvent;
pub use ;