-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_models.js
More file actions
35 lines (31 loc) · 1 KB
/
Copy pathlist_models.js
File metadata and controls
35 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import dotenv from 'dotenv';
dotenv.config();
const apiKey = process.env.GEMINI_API_KEY;
if (!apiKey) {
console.error("No GEMINI_API_KEY found in environment variables.");
process.exit(1);
}
async function listModels() {
console.log("Fetching model list...");
const url = `https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status} - ${await response.text()}`);
}
const data = await response.json();
console.log("Available Models:");
if (data.models) {
data.models.forEach(m => {
if (m.name.includes('gemini')) {
console.log(`- ${m.name}`);
}
});
} else {
console.log("No models found in response:", data);
}
} catch (error) {
console.error("Error fetching models:", error);
}
}
listModels();