Skip to main content
Google provides two SDKs relevant for tracing — choose based on what you’re building:
SDKUse caseIntegration
Google ADKFull agent framework (multi-agent, tools, sessions)AgentXADKPlugin
Google Gen AIRaw Gemini API calls (generate_content)patch_genai_client

Google ADK

Install:
pip install "agentx-python[google-adk]" google-adk
Register AgentXADKPlugin in the plugins list when constructing the ADK Runner. Every subsequent runner.run() call is traced automatically.
import os
from agentx import AgentX
from agentx.integrations.google_adk import AgentXADKPlugin
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools import FunctionTool
from google.genai import types

os.environ["GEMINI_API_KEY"] = "xxxxxxxxxxxxxxxxxxxx"

client = AgentX(
    api_key="agx-xxxxxxxxxxxxxxxx",
    workspace_id="xxxxxxxxxxxx",  # optional
)

def get_policy(topic: str) -> dict:
    """Return the company policy for a given topic."""
    db = {
        "cancel": "Go to Account → Subscription → Cancel.",
        "trial": "14-day free trial, no credit card required.",
        "refund": "Full refund within 30 days.",
    }
    return {"result": db.get(topic.lower(), "No policy found.")}


agent = Agent(
    name="support_agent",
    instruction="You are a helpful support agent. Use get_policy to look up policies.",
    tools=[FunctionTool(func=get_policy)],
)

runner = Runner(
    agent=agent,
    app_name="support-app",
    session_service=InMemorySessionService(),
    plugins=[
        AgentXADKPlugin(
            tracer=client.tracer,
            name="support-agent",
            metadata={"env": "production"},
        )
    ],
)

session = runner.session_service.create_session_sync(
    app_name="support-app", user_id="user-1"
)
for event in runner.run(
    user_id="user-1",
    session_id=session.id,
    new_message=types.Content(
        role="user", parts=[types.Part(text="How do I cancel my subscription?")]
    ),
):
    if event.is_final_response():
        print(event.content.parts[0].text)

client.tracer.flush(timeout=10)

What gets traced

FieldSource
inputUser message text from on_user_message_callback
outputLast model reply text from after_model_callback
latencyMsWall-clock time from before_run_callback to after_run_callback
modelllm_request.model from before_model_callback
toolCallsEach after_tool_callbackname, input, output, latencyMs

AgentXADKPlugin reference

AgentXADKPlugin(
    tracer: Tracer,
    name: str = "google-adk-agent",
    metadata: dict | None = None,
    session_id: str | None = None,
)
ParameterDescription
tracerclient.tracer from your AgentX instance
nameFallback label when the agent has no name set
metadataStatic key-value metadata attached to every trace
session_idLinks traces from the same conversation thread

Google Gen AI (raw Gemini API)

Install:
pip install "agentx-python[google-genai]" google-genai
Call patch_genai_client() once after creating your genai.Client. All subsequent client.models.generate_content() calls are traced automatically.
import os
from agentx import AgentX
from agentx.integrations.google_genai import patch_genai_client
from google import genai
from google.genai import types

client = AgentX(
    api_key="agx-xxxxxxxxxxxxxxxx",
    workspace_id="xxxxxxxxxxxx",  # optional
)

genai_client = genai.Client(api_key="GEMINI_API_KEY")

patch_genai_client(
    genai_client,
    tracer=client.tracer,
    name="gemini-support-agent",
    metadata={"env": "production"},
)

# Regular call
response = genai_client.models.generate_content(
    model="gemini-3.5-flash",
    contents="How do I cancel my subscription?",
)
print(response.text)

# or Streaming call
for chunk in genai_client.models.generate_content_stream(
    model="gemini-3.5-flash",
    contents="What is your refund policy?",
):
    print(chunk.text, end="", flush=True)

client.tracer.flush(timeout=10)

patch_genai_client() reference

patch_genai_client(
    client: genai.Client,
    tracer: Tracer,
    name: str = "gemini-agent",
    metadata: dict | None = None,
    session_id: str | None = None,
) -> None
ParameterDescription
clientThe genai.Client() instance to patch
tracerclient.tracer from your AgentX instance
nameLabel shown in the AgentX UI for every trace
metadataStatic key-value metadata attached to every trace
session_idLinks traces from the same conversation thread
Calling patch_genai_client() on an already-patched client is a no-op.
Call tracer.flush() before your process exits in scripts or one-shot jobs. In long-running servers it is not required — traces drain automatically in the background.