listModels method

Future<List<ModelInfo>> listModels()

Returns a list of available models from this provider.

This method allows you to programmatically discover which models are available from the provider. The returned list contains ModelInfo objects with metadata about each model.

By default, this returns an empty list. Providers that support model listing will override this method to return the actual available models.

Example:

final chatModel = ChatOpenAI(apiKey: '...');
final models = await chatModel.listModels();
for (final model in models) {
  print('${model.id} - ${model.displayName ?? ""}');
}

Note: Not all providers support model listing. For providers that don't support this feature, this method returns an empty list.

Implementation

Future<List<ModelInfo>> listModels() async => [];