The Gemini API lets you access the latest generative models from Google. This API reference provides detailed information for the classes and methods available in the Gemini API SDKs. Pick a language and follow the setup steps to get started building.
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
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
If you're just getting started, check out the following guides, which will help you understand the Gemini API programming model:
You might also want to check out the capabilities guides, which introduce different Gemini API features and provide code examples: