Laminar automatically instruments the official Google Gemini package with a single line of code, allowing you to trace and monitor all your Gemini API calls without modifying your existing code. This provides complete visibility into your AI application’s performance, costs, and behavior.
Just add a single line at the start of your application or file to instrument Gemini with Laminar.
Copy
from lmnr import Laminarfrom google import genaiimport osfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()# This single line instruments all Gemini API callsLaminar.initialize()# Initialize Gemini client as usualclient = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
# Make API calls to Gemini as you normally wouldresponse = client.models.generate_content( model="gemini-2.5-flash-preview-04-17", contents="Tell me a short story about a robot learning to paint.")print(response.text)
All Gemini API calls are now automatically traced in Laminar.