Skip to main content
Automatically capture all Gemini model calls made through the google-genai SDK.

Install

Set up

Usage

Once initialized, all Gemini calls are captured automatically — including tool-call requests:

Verify

Run your code and confirm the trace arrives:
  1. In the TraceRoot UI: Navigate to Tracing > Traces in TraceRoot Cloud. You should see a trace with root span GenerateContent (or GenerateContentStream when streaming).
  2. Via the CLI: Run traceroot traces list to inspect your recent traces from the terminal.

What gets captured

Limitations

  • When passing Python functions as tools, the SDK’s automatic function calling executes the entire tool loop inside a single generate_content call, which produces one span priced on the final model call only. For accurate per-step spans and cost, pass function declarations or set automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True) and run the loop manually.

Run the example

Clone the repo and run a complete agent end-to-end.

Python

Run the Python example

Next steps

Python SDK Reference

Explore the full Python SDK reference and instrumentation options.

Cost Tracking

Learn how TraceRoot calculates token costs and tracks model spend.