typesafe_ai/config.rs
1use std::time::Duration;
2
3/// Configuration shared by the blocking and asynchronous HTTP clients.
4///
5/// Credentials are supplied separately when constructing a client.
6///
7/// ```
8/// use std::time::Duration;
9///
10/// use typesafe_ai::ClientConfig;
11///
12/// let config = ClientConfig {
13/// timeout: Duration::from_secs(20),
14/// max_retries: 0,
15/// ..ClientConfig::default()
16/// };
17/// ```
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct ClientConfig {
20 /// API base URL.
21 ///
22 /// Defaults to `https://api.typesafe.ai`. Path prefixes are preserved when the
23 /// `/v1/systemone` endpoint is appended.
24 pub base_url: String,
25 /// Timeout for each complete HTTP attempt, including its response body.
26 ///
27 /// Defaults to 60 seconds.
28 pub timeout: Duration,
29 /// Number of retries after the initial attempt.
30 ///
31 /// Defaults to two. Clients retry only HTTP 429 and 529 responses.
32 pub max_retries: u32,
33}
34
35impl Default for ClientConfig {
36 fn default() -> Self {
37 Self {
38 base_url: "https://api.typesafe.ai".to_owned(),
39 timeout: Duration::from_secs(60),
40 max_retries: 2,
41 }
42 }
43}