pub struct AiClientBuilder { /* private fields */ }Expand description
Builder for creating clients with custom configuration.
Keep this surface area small and predictable (developer-friendly).
Implementations§
Source§impl AiClientBuilder
impl AiClientBuilder
pub fn new() -> Self
Sourcepub fn protocol_path(self, path: String) -> Self
pub fn protocol_path(self, path: String) -> Self
Set custom protocol directory path.
Sourcepub fn hot_reload(self, enable: bool) -> Self
pub fn hot_reload(self, enable: bool) -> Self
Enable hot reload of protocol files.
Sourcepub fn with_fallbacks(self, fallbacks: Vec<String>) -> Self
pub fn with_fallbacks(self, fallbacks: Vec<String>) -> Self
Set fallback models.
Sourcepub fn strict_streaming(self, enable: bool) -> Self
pub fn strict_streaming(self, enable: bool) -> Self
Enable strict streaming validation (fail fast when streaming config is incomplete).
This is intentionally opt-in to preserve compatibility with partial manifests.
Sourcepub fn feedback_sink(self, sink: Arc<dyn FeedbackSink>) -> Self
pub fn feedback_sink(self, sink: Arc<dyn FeedbackSink>) -> Self
Inject a feedback sink. Default is a no-op sink.
Sourcepub fn max_inflight(self, n: usize) -> Self
pub fn max_inflight(self, n: usize) -> Self
Limit maximum number of in-flight requests/streams. This is a simple backpressure mechanism for production safety.
Sourcepub fn circuit_breaker_default(self) -> Self
pub fn circuit_breaker_default(self) -> Self
Enable a minimal circuit breaker.
Defaults can also be enabled via env:
AI_LIB_BREAKER_FAILURE_THRESHOLD(default 5)AI_LIB_BREAKER_COOLDOWN_SECS(default 30)
Sourcepub fn rate_limit_rps(self, rps: f64) -> Self
pub fn rate_limit_rps(self, rps: f64) -> Self
Enable a minimal token-bucket rate limiter.
- Prefer configuring via env to keep API surface small:
AI_LIB_RPS(requests per second)AI_LIB_RPM(requests per minute)
Sourcepub fn base_url_override(self, base_url: impl Into<String>) -> Self
pub fn base_url_override(self, base_url: impl Into<String>) -> Self
Override the base URL from the protocol manifest.
This is primarily for testing with mock servers. In production, use the base_url defined in the protocol manifest.