Generative AI with Node.js in Hindi #14 Gemini setup with key in Node js

Gemini setup with key in Node js


Steps :-

  1. Login to aistudio.google.com
  2. Generate key
  3. Install @google/genai npm package
  4. Write and test code for basic answers
  5. Interview Question
  6. Code and Notes


import {GoogleGenAI} from '@google/genai'
import dotenv from 'dotenv'
dotenv.config();

const googleAI = new GoogleGenAI({apiKey:process.env.geminiKey})

async function main(){
const response = await googleAI.models.generateContent({
model:"gemini-2.5-flash",
contents:"tell me table of 39"
})
console.log(response.text)
}

main()