RemoteLanguageModel.create constructor

RemoteLanguageModel.create(
  1. ProviderConfig config, {
  2. String? apiKey,
  3. Client? client,
  4. Duration timeout = const Duration(seconds: 90),
})

The adapter for config's protocol. apiKey may be null for servers that need none (a local Ollama). Pass a shared client to reuse connections; otherwise one is created and released by close.

Implementation

factory RemoteLanguageModel.create(
  ProviderConfig config, {
  String? apiKey,
  http.Client? client,
  Duration timeout = const Duration(seconds: 90),
}) => switch (config.protocol) {
  ProviderProtocol.openAiCompatible => OpenAiCompatibleModel(
    config: config,
    apiKey: apiKey,
    client: client,
    timeout: timeout,
  ),
  ProviderProtocol.anthropic => AnthropicModel(
    config: config,
    apiKey: apiKey,
    client: client,
    timeout: timeout,
  ),
};