Gemini

Gemini is a family of multimodal large language models developed by Google DeepMind.

You can check out the Colab Notebook if you’d like to jump straight to the code:

Open In Colab

Getting Started

First, ensure you have both opik and google-genai packages installed:

$pip install opik google-genai

In addition, you can configure Opik using the opik configure command which will prompt you for the correct local server address or if you are using the Cloud platform your API key:

$opik configure

Configuring Gemini

In order to configure Gemini, you will need to have:

Once you have these, you can set them as environment variables:

{pytest_codeblocks_skip=true}
1import os
2
3os.environ["GOOGLE_API_KEY"] = "" # Your Google AI Studio Gemini API Key

Tracking Gemini calls

1from google import genai
2from opik import track
3from opik.integrations.genai import track_genai
4
5client = genai.Client()
6gemini_client = track_genai(client)
7
8prompt = "Hello world"
9
10response = client.models.generate_content(model="gemini-2.0-flash-001", contents=prompt)
11print(response.text)