Context
The Gemini Live API exposes usage metadata including promptTokenCount, responseTokenCount, thoughtsTokenCount, and totalTokenCount.
The official @google/genai SDK exposes this through LiveServerMessage.usageMetadata in the live.connect onmessage callback:
The Gemini 3.1 Flash Live pricing page also states that thinking tokens are included in output pricing:
Current behavior
With the Node.js Google realtime plugin, the provider Usage message is handled internally and normalized into RealtimeModelMetrics.
Current plugin source maps promptTokenCount, responseTokenCount, and totalTokenCount to inputTokens, outputTokens, and totalTokens, but does not expose thoughtsTokenCount or whether optional usage fields were present:
Environment used for the observation:
@livekit/agents 1.8.1
@livekit/agents-plugin-google 1.8.1
@google/genai 2.22.0
- Gemini Developer API
gemini-3.1-flash-live-preview
In a short synthetic session, a provider message like this was observed:
{
"usageMetadata": {
"promptTokenCount": 397,
"responseTokenCount": 49,
"thoughtsTokenCount": 26,
"totalTokenCount": 446
}
}
The corresponding LiveKit metric exposed input/output/total values but did not contain the thoughts count or field presence.
This prevents consumers from distinguishing:
thoughtsTokenCount was explicitly 0
- the provider omitted the field
- the plugin discarded the field
The request is for numeric usage metadata only. Thought text and thought summaries should not be forwarded to user-visible transcripts or TTS.
Question
Is exposing raw Gemini Live UsageMetadata (especially thoughtsTokenCount) in the Node.js Google realtime plugin the right scope for this repository, or should this feature be proposed in the canonical livekit/agents repository shown by the issue chooser?
Possible API shape
If this belongs in agents-js, a small provider-specific API could expose the raw usage before normalization, for example:
- an optional usage callback on the Google realtime model, or
- a provider-specific usage event on the realtime session.
The callback/event would provide the read-only provider usage object together with the generation/request identity. Existing RealtimeModelMetrics fields should remain backward compatible.
The implementation should preserve optional field presence and should not require consumers to infer reasoning tokens as:
totalTokens - inputTokens - outputTokens
The Live API reference and Google SDK type definitions currently describe totalTokenCount differently, so the provider field is preferable to a derived value.
Related issues checked
Context
The Gemini Live API exposes usage metadata including
promptTokenCount,responseTokenCount,thoughtsTokenCount, andtotalTokenCount.The official
@google/genaiSDK exposes this throughLiveServerMessage.usageMetadatain thelive.connectonmessagecallback:The Gemini 3.1 Flash Live pricing page also states that thinking tokens are included in output pricing:
Current behavior
With the Node.js Google realtime plugin, the provider Usage message is handled internally and normalized into
RealtimeModelMetrics.Current plugin source maps
promptTokenCount,responseTokenCount, andtotalTokenCounttoinputTokens,outputTokens, andtotalTokens, but does not exposethoughtsTokenCountor whether optional usage fields were present:Environment used for the observation:
@livekit/agents1.8.1@livekit/agents-plugin-google1.8.1@google/genai2.22.0gemini-3.1-flash-live-previewIn a short synthetic session, a provider message like this was observed:
{ "usageMetadata": { "promptTokenCount": 397, "responseTokenCount": 49, "thoughtsTokenCount": 26, "totalTokenCount": 446 } }The corresponding LiveKit metric exposed input/output/total values but did not contain the thoughts count or field presence.
This prevents consumers from distinguishing:
thoughtsTokenCountwas explicitly 0The request is for numeric usage metadata only. Thought text and thought summaries should not be forwarded to user-visible transcripts or TTS.
Question
Is exposing raw Gemini Live
UsageMetadata(especiallythoughtsTokenCount) in the Node.js Google realtime plugin the right scope for this repository, or should this feature be proposed in the canonicallivekit/agentsrepository shown by the issue chooser?Possible API shape
If this belongs in
agents-js, a small provider-specific API could expose the raw usage before normalization, for example:The callback/event would provide the read-only provider usage object together with the generation/request identity. Existing
RealtimeModelMetricsfields should remain backward compatible.The implementation should preserve optional field presence and should not require consumers to infer reasoning tokens as:
The Live API reference and Google SDK type definitions currently describe
totalTokenCountdifferently, so the provider field is preferable to a derived value.Related issues checked
thoughtsTokenCountexposure in the Node plugin.