2026-01-15 15:53:44 +00:00
|
|
|
import 'package:google_generative_ai/google_generative_ai.dart';
|
2026-01-29 15:54:22 +00:00
|
|
|
import 'package:ponshu_room_lite/secrets.dart';
|
2026-01-15 15:53:44 +00:00
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
|
final apiKey = Secrets.geminiApiKey;
|
|
|
|
|
print('Checking models for API Key: ${apiKey.substring(0, 5)}...');
|
|
|
|
|
|
|
|
|
|
// We can't easily "list" models with the package unless we use the REST API manually or specific helper.
|
|
|
|
|
// Actually, google_generative_ai doesn't have a 'listModels' helper easily accessible in the logic.
|
|
|
|
|
// We will brute-force check the likely candidates.
|
|
|
|
|
|
|
|
|
|
final candidates = [
|
|
|
|
|
'gemini-1.5-flash',
|
|
|
|
|
'gemini-1.5-flash-001',
|
|
|
|
|
'gemini-1.5-flash-latest',
|
|
|
|
|
'gemini-1.5-pro',
|
|
|
|
|
'gemini-1.5-pro-001',
|
|
|
|
|
'gemini-1.0-pro',
|
|
|
|
|
'gemini-2.0-flash-exp',
|
|
|
|
|
'gemini-2.5-flash', // The one that worked before
|
|
|
|
|
'gemini-pro',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for (final modelName in candidates) {
|
|
|
|
|
print('\n----------------------------------------');
|
|
|
|
|
print('Testing Model: $modelName');
|
|
|
|
|
try {
|
|
|
|
|
final model = GenerativeModel(model: modelName, apiKey: apiKey);
|
|
|
|
|
final response = await model.generateContent([Content.text('Test')]);
|
|
|
|
|
print('✅ AVAILABLE. Response: ${response.text?.trim()}');
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.toString().contains('404') || e.toString().contains('not found')) {
|
|
|
|
|
print('❌ 404 NOT FOUND');
|
|
|
|
|
} else if (e.toString().contains('429') || e.toString().contains('Quota')) {
|
|
|
|
|
print('⚠️ 429 QUOTA EXCEEDED (But Model Exists!)');
|
|
|
|
|
} else {
|
|
|
|
|
print('❌ ERROR: $e');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|