Expand description
§HTTP Client Implementation
Provides a robust HTTP client for communicating with the Zhipu AI API. This module implements connection pooling, error handling, and request/response processing.
§Features
- Connection Pooling - Reuses HTTP connections for better performance
- Error Handling - Comprehensive error parsing and reporting
- Authentication - Bearer token authentication support
- Retry with Jitter - Automatic retry with exponential backoff and random jitter
- Sensitive Data Masking - Automatic masking of API keys in logs
- Structured Logging - Uses tracing for detailed request/response logging
§Usage
The HttpClient trait provides a standardized interface for making HTTP
requests to the Zhipu AI API endpoints.
§Retry Configuration
The HTTP client supports configurable retry behavior:
ⓘ
use zai_rs::client::http::HttpClientConfig;
let config = HttpClientConfig::builder()
.max_retries(5)
.timeout(Duration::from_secs(120))
.retry_delay(RetryDelay::exponential(Duration::from_millis(100), Duration::from_secs(10)))
.build();Structs§
- Http
Client Config - Configuration for HTTP client behavior.
- Http
Client Config Builder - Builder for creating
HttpClientConfiginstances.
Enums§
- Retry
Delay - Retry delay strategy.
Traits§
- Http
Client - Trait for HTTP clients that communicate with the Zhipu AI API.
Functions§
- http_
client_ with_ config - Get or create an HTTP client with the specified configuration