availableModels property.
Method Signature
Parameters
The AI provider to fetch models from. The provider must support the models API endpoint.
Optional AbortController to cancel the fetch operation.
Return Type
A promise that resolves to an array of available model names.The method also automatically updates
provider.availableModels with the fetched list.Examples
Basic Usage
Legacy Usage (Deprecated)
With AbortController
Fetching for Multiple Providers
Using Fetched Models in UI
Checking Model Availability
Automatic Updates
When
fetchModels() is called, it automatically updates the provider.availableModels property. This means you can access the models list directly from the provider object after fetching:When to Use
You typically don’t need to call this method manually. The AI Providers plugin automatically fetches models when needed.However,
fetchModels() is useful when:- Building custom provider selection UI
- Validating that a specific model is available
- Refreshing the model list after provider changes
- Implementing model discovery features