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 Go 1.20+, install the generative-ai-go package in your module directory using the go get command:

go get github.com/google/generative-ai-go

Make your first request

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

model := client.GenerativeModel("gemini-1.5-flash")
resp, err := model.GenerateContent(ctx, genai.Text("Write a story about a magic backpack."))
if err != nil {
	log.Fatal(err)
}

printResponse(resp)

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: