Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation
G
Integration

Google Gemini

Automatic tracing for Google Gemini API calls including Gemini 1.5 Pro, Flash, and multimodal capabilities.

Prerequisites

  • Google AI API key
  • Lanternfish SDK installed
1

Install the SDK

bash
pip install "lanternfish[gemini]"
2

Initialize with auto-instrument

python
import os
import lanternfish
from google import genai

# Simply call instrument() and Gemini is auto-traced!
lanternfish.instrument(
    api_key=os.environ["LANTERNFISH_API_KEY"],
    endpoint=os.environ["LANTERNFISH_ENDPOINT"],
)

client = genai.Client()
3

Use as normal — tracing is automatic

python
# Google Gemini calls are automatically traced
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain quantum computing in simple terms"
)

# Captures: model metadata, prompt/response tokens, latency
print(response.text)

What Lanternfish captures

  • Complete trace timeline
  • Token usage and cost
  • Latency metrics
  • Tool and function calls
  • Error tracking
  • Model information

Next steps