Skip to main content
In this cookbook, you’ll learn how to easily integrate Maxim’s powerful tracing into your GenAI app powered by Google Gemini. We’ll walk through a simple example that shows how to set up the integration, trace requests, and log tool calls.

Prerequisites

1. Load Environment Variables

First, load your API keys from a .env file or your environment.

2. Initialize Maxim and Gemini Clients

Set up the Maxim logger and wrap the Gemini client for tracing.

3. Create the Gemini Client with Maxim Tracing

4. (Optional) Define a Tool Function

You can trace tool calls (function calls) as part of your workflow. For example, a weather function:

5. Generate Content with Tracing

Now, make a request to Gemini and trace it with Maxim. You can also pass tool functions for tool-calling scenarios.

6. View Traces in Maxim

All requests, responses, and tool calls are now automatically traced and can be viewed in your Maxim dashboard.

Full Example

Gif
For more details, see the Maxim Python SDK documentation.

Resources

Cookbook Code

Python Notebook for Gemini & Maxim