models static method
Get the list of available models from the Pollinations API. @return A Future that resolves to a list of models. Note: This method is static and can be called without creating an instance of TextAi.
Implementation
static Future<List<String>> models() async {
final response = await http
.get(
Uri.parse("https://${ApiConfig.getEndpoint(Api.text)}/models"),
headers: ApiConfig.headers,
)
.timeout(Duration(seconds: ApiConfig.timeout));
if (response.statusCode == 200) {
List<dynamic> modelsJson = json.decode(response.body);
return modelsJson.map((model) => model["name"].toString()).toList();
}
return [];
}