Provider & Model Discovery
Dartantic supports discovering the available providers that Dartantic supports and the models that are available from each provider.
Available Providers
You can list the available providers using the Agent.providers
property. The
result is a map of provider names to provider factory functions.
Available Models
You can list the available models from a provider using the
Provider.listModels()
method. This returns a list of ModelInfo
objects,
which include the model name, what kinds of operations it supports, and whether
it's a stable production model or a preview/experimental model. For example:
import 'package:dartantic_ai/dartantic_ai.dart';
void main() async {
final provider = Agent.providerFor('openai');
final models = await provider.listModels();
for (final model in models) {
final status = model.stable ? 'stable' : 'preview';
print('${model.providerName}:${model.name} [$status] (${model.kinds})');
}
}
Model Stability Detection
The stable
field helps you distinguish between production-ready models and
experimental ones. For example:
- Stable models:
gpt-4o
,gemini-2.5-pro
,text-embedding-3-large
- Preview/experimental models:
gpt-4-turbo-preview
,gemini-2.5-pro-exp-03-25
,o1-preview
Until there's an API from the model providers (I'm looking at you, Google and OpenAI), models are classified using heuristics based on their names, looking for patterns like "preview", "experimental", "latest", version numbers, and date suffixes. Please take this information with a grain of salt.
For a working example, take a look at list_models.dart.