Google Gen AI provides the Gemini family of large language models through the Google Gen AI Python SDK. Arize AX captures every Gemini API call — chat completions, tool calls, and token usage — via theDocumentation Index
Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
openinference-instrumentation-google-genai package. The same instrumentor also covers calls routed through Vertex AI when the SDK is configured against Vertex.
Prerequisites
- Python 3.10+
- An Arize AX account (sign up)
- A
GEMINI_API_KEYfrom Google AI Studio
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
Setup tracing
Run Google GenAI
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
google-genai-tracing-example. - You should see a new trace within ~30 seconds containing a
GenerateContentLLM span with the prompt, response, and token usage attached. - If no traces appear, see Troubleshooting.
Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.py. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. - Google GenAI spans missing but other spans present.
GoogleGenAIInstrumentor().instrument(...)must run before anyfrom google import genaiimport. Make sureinstrumentation.pyis the first import in your entry point. 401/403from Gemini. VerifyGEMINI_API_KEYis set and has access to the model in the example. Swapgemini-2.5-flashfor a model your key can call.404 NOT_FOUNDfor the model. Google occasionally retires older Gemini aliases for new users. Ifgemini-2.5-flashreturns 404, list models withclient.models.list()and pick a current one.- Using Vertex AI instead of the Gemini API. Configure the SDK against Vertex per Google’s GenAI SDK docs (set
GOOGLE_GENAI_USE_VERTEXAI,GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION). The same instrumentor captures Vertex calls — only the credential setup differs.