Google GenAI Integration with Future AGI for Gemini Tracing
Set up Google GenAI with Future AGI tracing. Install traceAI-google-genai to capture and monitor Gemini model interactions automatically.
Trace Google GenAI model calls in Future AGI using the Google GenAI instrumentor.
1. Installation
Install the traceAI and Google GenAI packages.
pip install traceAI-google-genai google-genai
2. Set Environment Variables
Set up your environment variables to authenticate with FutureAGI.
import os
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
The instrumentor captures request and response content by default, including prompts and generated text. To hide input, output and request parameters in traces, set these before initializing instrumentation:
export FI_HIDE_INPUTS=true
export FI_HIDE_OUTPUTS=true
export FI_HIDE_LLM_INVOCATION_PARAMETERS=true
See trace masking settings for additional controls. Do not treat input/output masking as a general-purpose scrubber for error text, user IDs, metadata or custom spans.
3. Initialize Trace Provider
Register the google_genai Observe project.
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="google_genai",
)
4. Instrument your Project
Instrument your project to enable automatic tracing.
from traceai_google_genai import GoogleGenAIInstrumentor
GoogleGenAIInstrumentor().instrument(tracer_provider=trace_provider)
5. Make a Google GenAI request
After initializing the instrumentor, use a Google GenAI client to make a request through Vertex AI. Set project to your Google Cloud project and configure Application Default Credentials.
from google import genai
from google.genai import types
client = genai.Client(vertexai=True, project="your_project_name", location="global")
content = types.Content(
role="user",
parts=[
types.Part.from_text(text="Hello how are you?"),
],
)
response = client.models.generate_content(
model="gemini-3.5-flash-lite", contents=content
)
print(response)
trace_provider.force_flush() # Export buffered spans before this script exits.
6. View the trace
In Future AGI, open Observe, select the google_genai project, and open the trace.
Questions & Discussion