OpenRouterProvider constructor

OpenRouterProvider({
  1. required String apiKey,
  2. required String model,
  3. Client? httpClient,
  4. Uri? endpoint,
  5. List<Map<String, Object?>>? tools,
  6. Map<String, Object?>? extraParams,
})

Creates an OpenRouter provider.

Pass httpClient to reuse an existing client (its lifecycle is then the caller's responsibility); otherwise one is created and closed by dispose. endpoint overrides the default completions URL, useful for a proxy in front of OpenRouter.

Implementation

OpenRouterProvider({
  required this.apiKey,
  required this.model,
  http.Client? httpClient,
  Uri? endpoint,
  this.tools,
  this.extraParams,
})  : _httpClient = httpClient ?? http.Client(),
      _ownsClient = httpClient == null,
      _endpoint =
          endpoint ?? Uri.parse('https://openrouter.ai/api/v1/chat/completions');