Google Gen AI
cetra traces calls to Gemini through the Google Gen AI SDK, including streamed answers, images in the input and reasoning tokens. For Vertex AI, see Vertex AI.
Install
Section titled “Install”pip install "cetra-sdk[google-genai]" google-genaiSet up
Section titled “Set up”import cetrafrom google import genai
cetra.init(instrument=["google-genai"])
client = genai.Client()client.models.generate_content( model="gemini-2.5-flash", contents="What is the weather in Paris?",)
cetra.flush()What you get
Section titled “What you get”- Each
generateContentcall is anllmspan with the input and output as chat messages. - A streamed call is captured as one
llmspan (OpenInference names itGenerateContentStream). - Reasoning tokens are recorded when Gemini reports them.
- An image in the input is stored as media and replaced by a reference, as for every other provider. See Media.
- Cache read tokens are recorded when Gemini reports them.
Limits
Section titled “Limits”- The fixtures were captured with
google-genai2.34.0 and these instrumentations: OpenInference 1.5.0, the official OpenTelemetryopentelemetry-instrumentation-google-genai1.1b1 and OpenLLMetry 0.62.4. - The provider name depends on the instrumentation:
gcp.gen_aifrom OpenInference andgcp.geminifrom the official OpenTelemetry one. cetra prices both from the same Gemini prices. - The
instrumentname is checked by an SDK test that imports the instrumentor when the extra is installed. cetra-sdk’s own spans for this name are not captured.
- Traces: read the trace as a tree and a timeline.
- Cost and tokens: how cost is computed from the token counts.
- Online rules: score these traces automatically.