Documentation Index
Fetch the complete documentation index at: https://docs.trodo.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
What auto-instruments
Two separate instrumentation packages, one per SDK:opentelemetry-instrumentation-google-generativeai— for thegoogle-generativeaiPyPI package (Gemini API).opentelemetry-instrumentation-vertexai— for thegoogle-cloud-aiplatform/vertexaipackage (Vertex AI).
| Call | Span kind | Auto-extracted |
|---|---|---|
GenerativeModel.generate_content | llm | model, tokens (usageMetadata), prompt, response |
GenerativeModel.generate_content_stream | llm | Same, accumulated |
GenerativeModel.start_chat → send_message | llm | Same, with chat history in input |
embed_content | llm | model, input tokens |
(Vertex) TextGenerationModel.predict (legacy PaLM) | llm | model, tokens |
google for Gemini, google-vertex for Vertex.
Install
Gemini minimum example
Vertex minimum example
Token extraction
Both SDKs returnusage_metadata with:
prompt_token_count→input_tokenscandidates_token_count→output_tokenstotal_token_count→ ignored (we recompute from inputs + outputs)
Function calling
Gemini’s function-calling loop alternatesgenerate_content calls and your tool executions. Wrap the tool side:
Auto vs manual cheat-table
| Operation | Auto? | Notes |
|---|---|---|
generate_content / stream | yes | — |
start_chat + send_message | yes | Each send = one span |
embed_content | yes | — |
File API (upload_file) | no | Out of scope — usually one-off |
Caching (CachedContent) | partial | Creation silent; usage reflected in span’s cached_content_token_count |
Vertex endpoint mode (Endpoint.predict) | no | Custom-trained models — wrap with trodo.llm + extractUsage |
Gotchas
- Node support is via REST only — there is no Google-provided first-party OTel instrumentation for the JS SDK. Use
trodo.llmortrodo.trackLlmCallwith the defaultextractUsage(which handlesusageMetadata). - The Gemini SDK and the Vertex SDK both expose a
GenerativeModelclass — the instrumentation packages are mutually non-interfering but you must install whichever one matches the SDK you import. - Thinking tokens (Gemini 2.5):
usage_metadata.thoughts_token_countis available on the span’s raw attributes but is not rolled intoinput_tokens/output_tokens— read it from the span detail drawer.