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 with building generative applications on your platform of choice.

Prerequisites

Install the Google AI SDK

Set up authentication

The easiest way to authenticate to the Gemini API is to configure an API key, as described in this section. If you need stricter access controls, you can use OAuth instead.

If you don't already have an API key, create one in Google AI Studio.

Get an API key from Google AI Studio

Then, configure your key.

Import the library

Make your first request

Use the generateContent method to generate text.

What's next

Now that you have a model client, you can start programming with the Gemini API. Read through the reference to learn how to use key API features:

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 Gemini API features and provide examples of programming with the SDKs:

Then, for more in-depth documentation of Gemini API methods and request parameters, browse the guides in this reference.