Skip to main content

Requirements

Env Variables

Initialize Logger

Initialize MaximGeminiClient

Make LLM Calls Using MaximGeminiClient

Maxim-specific Headers

The Gemini instrumentation supports additional headers via the http_options.headers parameter within the config dictionary to enhance trace metadata and organization. You can use the following headers:
  • x-maxim-trace-id: Associate LLM calls with a specific trace ID (UUID string). All calls with the same trace ID will be grouped together in a single trace.
  • x-maxim-trace-tags: Add custom tags to traces as a JSON string containing key-value pairs. Useful for filtering and organizing traces.
  • x-maxim-generation-name: Assign a custom name to a specific generation/LLM call within a trace (string).
  • x-maxim-session-id: Associate traces with a specific session ID (string).

Example: Using HTTP Headers

Advanced Use-Cases

Function Calling Support

Define function tools

Make calls with function tools

Capture Multiple LLM Calls in One Trace

Initialize Maxim SDK and Gemini Client
Create a new trace externally
Make LLM calls and use this trace id
Keep adding LLM calls All LLM calls with the same trace_id parameter will be added to the declared trace.

Capture Multi-Turn Conversations

Initialize Maxim SDK and Gemini Client
Create a new trace externally and add it to a session
Make LLM calls and use this trace id
Create additional traces in the same session To add more conversations to the same session, create new traces with the same session_id:
Gif

Resources

Google Gemini integration Notebook (Colab)