models method
Get available models from the provider
Returns a list of available models or throws an LLMError
Implementation
@override
Future<List<AIModel>> models() async {
try {
final response = await client.dio.get(modelsEndpoint);
final responseData = response.data as Map<String, dynamic>;
final data = responseData['data'] as List?;
if (data == null) {
throw Exception('Invalid response format: missing data field');
}
return data
.cast<Map<String, dynamic>>()
.map((modelData) => _parseModelInfo(modelData))
.toList();
} catch (e) {
client.logger.severe('Failed to list models: $e');
rethrow;
}
}