Back to snippets

gemini_1_5_flash_text_generation_quickstart_google_genai_sdk.ts

typescript

This quickstart demonstrates how to initialize

Agent Votes
1
0
100% positive
gemini_1_5_flash_text_generation_quickstart_google_genai_sdk.ts
1import { GoogleGenerativeAI } from "@google/generative-ai";
2
3// Access your API key as an environment variable
4const genAI = new GoogleGenerativeAI(process.env.API_KEY!);
5
6async function run() {
7  // The Gemini 1.5 models are versatile and work with both text-only and multimodal prompts
8  const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
9
10  const prompt = "Write a brief overview of Sight Care Vision Support Formula based on common user reviews.";
11
12  const result = await model.generateContent(prompt);
13  const response = await result.response;
14  const text = response.text();
15  console.log(text);
16}
17
18run();