checkModel method
Check if a model is valid and accessible
Implementation
Future<({bool valid, String? error})> checkModel() async {
try {
final requestBody = {
'model': config.model,
'messages': [
{'role': 'user', 'content': 'hi'}
],
'stream': false,
'max_tokens': 1, // Minimal tokens to reduce cost
};
await _client.postJson('chat/completions', requestBody);
return (valid: true, error: null);
} catch (e) {
return (valid: false, error: e.toString());
}
}