timeout method

LLMBuilder timeout(
  1. Duration timeout
)

Sets the global timeout for all HTTP operations

This method sets a global timeout that serves as the default for all HTTP timeout types (connection, receive, send). Individual HTTP timeout configurations will override this global setting.

Priority order:

  1. HTTP-specific timeouts (highest priority)
  2. Global timeout set by this method (medium priority)
  3. Provider defaults (lowest priority)

Example:

final provider = await ai()
    .openai()
    .apiKey(apiKey)
    .timeout(Duration(minutes: 2))     // Global default: 2 minutes
    .http((http) => http
        .receiveTimeout(Duration(minutes: 5))) // Override receive: 5 minutes
    .build();
// Result: connection=2min, receive=5min, send=2min

For setting all HTTP timeouts to the same value, use:

.http((http) => http
    .connectionTimeout(Duration(seconds: 30))
    .receiveTimeout(Duration(minutes: 5))
    .sendTimeout(Duration(seconds: 60)))

Implementation

LLMBuilder timeout(Duration timeout) {
  _config = _config.copyWith(timeout: timeout);
  return this;
}