Google Gemini Integration

Updated on Aug 14, 2026

Use this integration when your app is implemented in Python or TypeScript.

Setup

  1. Install SDK
bash
pip install progress-observability
  1. Instrument your app
python
Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY")
)
  1. Complete example
python
import os

from google import genai
from google.genai import types
from dotenv import load_dotenv

from progress.observability import Observability

load_dotenv()

# LLM INSTRUMENTATION
Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY"),
)


def main() -> None:
    client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
    model = os.getenv("GEMINI_MODEL", "gemini-2.5-flash")

    response = client.models.generate_content(
        model=model,
        contents="What is the capital of France?",
        config=types.GenerateContentConfig(
            system_instruction="You are a helpful AI assistant.",
            max_output_tokens=256,
        ),
    )



try:
    main()
finally:
    Observability.shutdown()

To get a richer trace tree when building agents on top of this provider, use the @agent, @tool, @workflow, or @task decorators. See the Python SDK for details.

  1. Install SDK
bash
npm install @progress/observability
  1. Instrument your app
TS
import '@progress/observability/register/hooks';
import { Observability } from '@progress/observability';
await Observability.instrument({
 appName: process.env.OBSERVABILITY_APP_NAME,
 apiKey: process.env.OBSERVABILITY_API_KEY
});
  1. Complete example
TS
import '@progress/observability/register/hooks';
import 'dotenv/config';

import { GoogleGenAI } from '@google/genai';
import { Observability } from '@progress/observability';

async function main() {
  await Observability.instrument({
    appName: process.env.OBSERVABILITY_APP_NAME,
    apiKey: process.env.OBSERVABILITY_API_KEY,
  });

  try {
    const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_AI_API_KEY });
    const model = process.env.GEMINI_MODEL ?? 'gemini-2.5-flash';

    const response = await ai.models.generateContent({
      model,
      contents: 'What is the capital of France?',
    });

  } finally {
    await Observability.shutdown();
  }
}

main().catch(e => { console.error(e); process.exitCode = 1; });

To get a richer trace tree when building agents on top of this provider, use the @agent, @tool, @workflow, or @task decorators. See the TypeScript SDK for details.

In this article
Setup
Not finding the help you need?
Contact Support