Gemini API quickstart

This quickstart shows you how to install your SDK of choice from the new Google Gen AI SDK, and then make your first Gemini API request.

Install the Gemini API library

Using Node.js v18+, install the Google Gen AI SDK for TypeScript and JavaScript using the following npm command:

npm install @google/genai

Make your first request

Get a Gemini API key in Google AI Studio

Use the generateContent method to send a request to the Gemini API.

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY" });

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-2.0-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

main();

What's next

Now that you made your first API request, you might want to explore the following guides that show Gemini in action: