http method

LLMBuilder http(
  1. HttpConfig configure(
    1. HttpConfig
    )
)

Configure HTTP settings using a fluent builder

This method provides a clean, organized way to configure HTTP settings without cluttering the main LLMBuilder interface.

Example:

final provider = await ai()
    .openai()
    .apiKey(apiKey)
    .http((http) => http
        .proxy('http://proxy.company.com:8080')
        .headers({'X-Custom-Header': 'value'})
        .connectionTimeout(Duration(seconds: 30))
        .enableLogging(true))
    .build();

Implementation

LLMBuilder http(HttpConfig Function(HttpConfig) configure) {
  final httpConfig = HttpConfig();
  final configuredHttp = configure(httpConfig);
  final httpSettings = configuredHttp.build();

  // Apply all HTTP settings as extensions
  for (final entry in httpSettings.entries) {
    _config = _config.withExtension(entry.key, entry.value);
  }

  return this;
}