const { GoogleGenAI } = require('@google/genai'); async function listModels() { const apiKey = 'AIzaSyBnrLw5W4NidP4w-70x59fcPolz0izMVfU'; // Hardcoded from .env console.log('Initializing with key:', apiKey.substring(0, 10) + '...'); try { const client = new GoogleGenAI({ apiKey }); console.log('Client initialized.'); // Try to list models. In new SDK it might be different. // Checking documentation or guessing. // Based on stack trace: client.models.list() is likely. const response = await client.models.list(); console.log('Models response:', response); if (response && response.models) { response.models.forEach(m => console.log(m.name)); } else { // It might be an async iterable for await (const model of response) { console.log(model.name); } } } catch (error) { console.error('Error listing models:', error); if (error.response) { console.error('Response data:', error.response.data); } } } listModels();