-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-key.js
More file actions
26 lines (18 loc) · 794 Bytes
/
Copy pathtest-key.js
File metadata and controls
26 lines (18 loc) · 794 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
26
const { GoogleGenerativeAI } = require("@google/generative-ai");
// PASTE YOUR NEW KEY INSIDE THE QUOTES BELOW 👇
const API_KEY = "AIzaSyBuOFeGFCwLF5roKJegepRmaFj6jaE6YRc";
async function testConnection() {
console.log("🔑 Testing Hardcoded Key:", API_KEY.substring(0, 10) + "...");
const genAI = new GoogleGenerativeAI(API_KEY);
try {
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
console.log("✅ Connection Successful! Generating content...");
const result = await model.generateContent("Hello, are you working?");
const response = await result.response;
console.log("🤖 Response:", response.text());
} catch (error) {
console.error("\n❌ FAILED:");
console.error(error.message);
}
}
testConnection();