listModels method

Future<List<String>> listModels({
  1. Duration? timeout,
})

Model identifiers the provider serves, sorted.

Implementation

Future<List<String>> listModels({Duration? timeout}) async {
  final json = await _transport.getJson(
    config.endpoint(_modelsPath),
    _headers,
    timeout: timeout,
  );
  final data = json is Map ? json['data'] : null;
  if (data is! List) {
    throw const SystemLlmException(SystemLlmException.invalidResponse);
  }
  return [
    for (final entry in data)
      if (entry is Map && entry['id'] is String) entry['id'] as String,
  ]..sort();
}