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
//! Process-wide shared [`reqwest::Client`].
//!
//! Each call to [`reqwest::Client::new`] loads the system TLS root store
//! (hundreds of certs), builds a fresh TLS config, and allocates a new
//! connection pool. Across ~10 providers that's hundreds of milliseconds
//! of startup cost on first use plus duplicated pools that cannot share
//! keep-alive connections.
//!
//! [`shared_client`] returns a single `Client` that every provider which
//! does not need custom builder options can clone (the `Client` is
//! internally reference-counted, so clones are O(1) and share the
//! underlying connection pool).
//!
//! Providers that need custom timeouts, proxies, or TLS settings
//! (`openai`, `vertex_*`, `gemini_web`, `openrouter`) continue to use
//! `Client::builder()` directly — those configurations cannot be
//! meaningfully shared anyway.
use Lazy;
use Client;
static SHARED: = new;
/// Return a handle to the process-wide shared `reqwest::Client`.
///
/// `Client` is cheap to clone — it wraps an `Arc` internally — so callers
/// should `.clone()` the returned reference into their own state.