Skip to main content

aimux_provider_utils/
lib.rs

1//! # aimux-provider-utils
2//!
3//! Shared utilities for provider implementations.
4//!
5//! Provides one-exchange HTTP helpers, response handlers, API key loading,
6//! header management, and URL utilities — the Rust equivalents of
7//! `@ai-sdk/provider-utils`. Operation retry and timeout live in `aimux-core`.
8
9pub mod api_key;
10mod download_guard;
11pub mod extract_response_headers;
12pub mod get_from_api;
13pub mod handle_fetch_error;
14pub mod headers;
15pub mod http;
16pub mod logging;
17pub mod multipart;
18pub mod post_to_api;
19pub mod read_response_with_size_limit;
20pub mod response_handler;
21pub mod retry;
22pub mod url;
23/// WebSocket client for realtime provider APIs (RFC-0028). Empty unless the
24/// `ws` feature is enabled.
25#[cfg(feature = "ws")]
26pub mod ws;
27
28pub use api_key::load_api_key;
29pub use download_guard::same_origin;
30pub use get_from_api::get_from_api;
31pub use headers::with_user_agent_suffix;
32pub use http::{
33    ExchangeContext, HttpBody, HttpRequest, ProxyConfig, init_proxy, shared_client, sleep_or_abort,
34};
35pub use logging::{body_logging_enabled, init_logging, redact_body, redact_error_context};
36pub use multipart::{MultipartForm, media_type_to_extension};
37pub use post_to_api::{post_form_data_to_api, post_json_to_api, post_to_api};
38pub use response_handler::{
39    ProviderErrorParts, ResponseHandler, ResponseHandlerInput, ResponseHandlerOutput,
40    create_binary_response_handler, create_event_source_response_handler,
41    create_json_error_response_handler, create_json_response_handler,
42    create_standard_json_error_response_handler, create_status_code_error_response_handler,
43    stream_error_api_call,
44};
45pub use retry::RetryConfig;
46pub use url::{validate_base_url, without_trailing_slash, without_trailing_slash_opt};