-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (18 loc) · 780 Bytes
/
index.js
File metadata and controls
26 lines (18 loc) · 780 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
// To get access to API key from .env:
// install 'dotenv', create .env file, place in key, require("dotenv").config
require("dotenv").config();
const API_KEY = process.env.GEMINI_API;
// import {GoogleGenerativeAI} from "@google/generative-ai";
const { GoogleGenerativeAI } = require("@google/generative-ai");
// Access your API key (see "Set up your API key" above)
const genAI = new GoogleGenerativeAI(API_KEY);
async function run() {
// For text-only input, use the gemini-pro model
const model = genAI.getGenerativeModel({ model: "gemini-pro"});
const prompt = "Write a story about a magic backpack."
const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
console.log(text);
}
// run();