Prerequisites
- Python 3.8+
- Maxim Python SDK (
pip install maxim-py
) - Google GenAI SDK (
pip install google-genai
) - python-dotenv (
pip install python-dotenv
) - A Google Gemini API key
- A Maxim API key
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

For more details, see the Maxim Python SDK documentation.