@google/generative-ai 모듈 설치:npm install @google/generative-ai
.env 파일에 API 키 설정:API_KEY=your_google_api_key
const { GoogleGenerativeAI } = require("@google/generative-ai");
const genAI = new GoogleGenerativeAI({ apiKey: process.env.API_KEY });
const response = await genAI.generate({
model: "models/gemini-1.5-flash",
prompt: "What is the capital of France?",
});
console.log(response.candidates[0].output);
.env 파일에 설정.http://localhost:8000/chat.Content-Type: application/json.{ "prompt": "Tell me about AI" }
// 이와같이 궁금한것을 물어 볼 수 있음
res.json() 응답 형태 점검.