google-genai SDK.
Setup
Usage
Once initialized, all Gemini calls are captured automatically — including tool calls:What Gets Captured
Run the example
Clone the repo and run a complete agent end-to-end.Python
Run the Python example
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Auto-instrument Google Gemini API calls via the GenAI SDK
google-genai SDK.
import traceroot
from traceroot import Integration
traceroot.initialize(integrations=[Integration.GOOGLE_GENAI])
import os
from google import genai
from google.genai import types
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
weather_tool = types.Tool(function_declarations=[
types.FunctionDeclaration(
name="get_weather",
description="Get current weather for a city",
parameters=types.Schema(
type="OBJECT",
properties={"city": types.Schema(type="STRING", description="City name")},
required=["city"],
),
)
])
# This call is automatically traced
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="What's the weather in Tokyo?",
config=types.GenerateContentConfig(tools=[weather_tool]),
)
print(response.text)
| Attribute | Description |
|---|---|
| Model | gemini-2.5-flash, gemini-2.0-pro, etc. |
| Contents | Input messages |
| Response | Generated text and function calls |
| Tokens | Input and output token counts |
| Cost | Calculated from token usage and model pricing |
| Latency | Request duration |