Google Gen AI
Logfire supports instrumenting calls to the Google Gen AI SDK (google-genai) with the logfire.instrument_google_genai() method.
Install logfire with the google-genai extra:
pip install 'logfire[google-genai]'
uv add 'logfire[google-genai]'
import os
from google.genai import Client
import logfire
# This is required for prompts and completions to be captured in the spans
os.environ['OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT'] = 'true'
logfire.configure()
logfire.instrument_google_genai()
client = Client()
response = client.models.generate_content(model='gemini-2.5-flash', contents=['Hi'])
print(response.text)
# Hello! How can I help you today?
This creates a span which shows the conversation in the Logfire UI:

logfire.instrument_google_genai() uses the GoogleGenAiSdkInstrumentor().instrument() method of the opentelemetry-instrumentation-google-genai package.