canUseModel method

Future<bool> canUseModel(
  1. String modelId
)

Returns whether the model with the given model id can be used
It returns true if the model is currently active and false otherwise
Example:

if (await groq.canUseModel(llama3_8b)) {
 final chat = groq.startNewChat(llama3_8b);
}

Implementation

Future<bool> canUseModel(String modelId) async {
  try {
    final model = await getModel(modelId);
    return model.isCurrentlyActive;
  } catch (e) {
    return false;
  }
}