-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-models.js
More file actions
25 lines (22 loc) · 791 Bytes
/
test-models.js
File metadata and controls
25 lines (22 loc) · 791 Bytes
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
const { GoogleGenerativeAI } = require("@google/generative-ai");
require("dotenv").config();
async function listModels() {
const apiKey = process.env.GEN_AI_API_KEY;
if (!apiKey) {
console.error("No API Key found in .env");
return;
}
const genAI = new GoogleGenerativeAI(apiKey);
try {
// The SDK doesn't have a direct listModels but we can try to use the rest client or just guess
// Actually, we can use the fetch API if we want to be sure
const response = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`,
);
const data = await response.json();
console.log("Available Models:", JSON.stringify(data, null, 2));
} catch (error) {
console.error("Error listing models:", error);
}
}
listModels();