1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Connect and idle timeouts for the HTTP transport of model clients.
use Duration;
/// Connect and idle timeouts for a model client's HTTP transport.
///
/// | Bound | Covers |
/// |-------|--------|
/// | `connect` | establishing the connection, TLS included |
/// | `idle` | each wait for data: the response headers, then every gap between body chunks of a streamed or complete response |
///
/// A request that gets no response headers within `idle`, a stream that stops sending data
/// for `idle`, and a complete response whose body stalls for `idle` all fail with
/// `ErrorCategory::Timeout` instead of holding the run, as does a connection not established
/// within `connect`; a long stream that keeps sending data is never cut off. The defaults are
/// 30 seconds to connect and 10 minutes idle, the request timeout of the official OpenAI and
/// Anthropic SDKs, which leaves room for reasoning models that think for minutes before
/// their first token. The OpenAI-compatible, OpenAI Responses, Azure OpenAI, Azure AI, Groq,
/// DeepSeek, OpenRouter, Ollama, and Bedrock clients apply them by default and take others
/// through `with_timeouts`; the Gemini API-key client applies them by default and takes
/// others through `GeminiModel::new_with_base_url_and_timeouts`. Bedrock applies them as the SDK's connect and read timeouts plus
/// a bound on each stream event; an SDK client passed to `BedrockClient::from_client` keeps
/// its own connect and read timeouts until `with_timeouts` replaces them.
///
/// # Example
///
/// ```
/// use std::time::Duration;
///
/// use adk_model::HttpTimeouts;
///
/// // Fail a stream that sends nothing for two minutes; pass to a client's `with_timeouts`.
/// let timeouts = HttpTimeouts::new(Duration::from_secs(10), Duration::from_secs(120));
/// assert_eq!(timeouts.idle, Duration::from_secs(120));
/// assert_eq!(HttpTimeouts::default(), HttpTimeouts::new(Duration::from_secs(30), Duration::from_secs(600)));
/// ```
/// The category of a transport failure: `Timeout` when a bound expired, before the response
/// headers or between body chunks, otherwise `Unavailable`.
pub