Spaces:
Sleeping
Sleeping
| require('dotenv').config({ path: '../.env' }); | |
| const { GoogleGenerativeAI } = require('@google/generative-ai'); | |
| async function listModels() { | |
| try { | |
| const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY); | |
| // The SDK might not have a direct listModels, so let's hit the REST API directly | |
| const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${process.env.GEMINI_API_KEY}`); | |
| const data = await response.json(); | |
| if (data.models) { | |
| const genModels = data.models.filter(m => m.supportedGenerationMethods.includes('generateContent')).map(m => m.name); | |
| console.log("AVAILABLE GEMINI MODELS:"); | |
| console.log(genModels.join('\n')); | |
| } else { | |
| console.log("Raw Response:", JSON.stringify(data, null, 2)); | |
| } | |
| } catch (e) { | |
| console.error("Error:", e); | |
| } | |
| } | |
| listModels(); | |