Gemini API reference

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 Python 3.9+, install the google-generativeai package using the following pip command:

pip install -q -U google-generativeai

Make your first request

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

import google.generativeai as genai

genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content("Explain how AI works")
print(response.text)

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: