Expand description
Provider-agnostic plumbing shared by every klieo-llm-* provider
crate.
The Anthropic, OpenAI, Gemini, and Ollama clients all duplicated the
same HTTP-client builder and the same reqwest::Error →
LlmError mapping. A tuning change had to land in four files;
security defaults (TLS redirect policy, connect timeout) could
silently drift between providers.
This crate centralises:
build_http_client+HttpDefaults— single factory with redirects disabled (CWE-200: bearer-token leak via cross-origin redirect).map_reqwest—reqwest::Error→LlmErrordispatch.retry_after_from_headers— RFC 7231Retry-Afterparser. Provider crates previously hardcodedretry_after_secs = 1; this lets them honour the upstream’s actual hint.
SSE-event decoding is NOT shared: the frame splitter itself is five lines per crate, and the per-provider event dispatch loop sitting on top is genuinely different (Anthropic typed events, OpenAI choices deltas, Gemini candidates, Ollama JSON-per-line). Sharing the splitter alone would add an abstraction without removing the bulk.
Re-exports§
pub use crate::error::map_reqwest;pub use crate::error::map_status_code;pub use crate::error::retry_after_from_headers;pub use crate::error::truncate_error_detail;pub use crate::error::StatusMessageKind;pub use crate::http::build_http_client;pub use crate::http::HttpDefaults;pub use crate::http::DEFAULT_HTTP_DEFAULTS;