Skip to content

feat: expose raw usage metadata in LLMTokenUsage for Gemini Live and OpenAI Realtime#44

Open
nihal0514 wants to merge 1 commit into
dograh-hq:mainfrom
nihal0514:expose-raw-usage-metadata
Open

feat: expose raw usage metadata in LLMTokenUsage for Gemini Live and OpenAI Realtime#44
nihal0514 wants to merge 1 commit into
dograh-hq:mainfrom
nihal0514:expose-raw-usage-metadata

Conversation

@nihal0514

Copy link
Copy Markdown

Overview

This pull request extends the core metrics layer to capture and pass through the rich multimodal usage metadata from both the Gemini Live and OpenAI Realtime speech-to-speech services.

Why is this needed?

Currently, the standard LLMTokenUsage metrics schema captures basic token fields (prompt, completion, cache_read, etc.) but strips away key modality breakdowns (such as audio-input, audio-output, tool-use, images, and videos). To perform accurate, granular multimodal cost-tracking and telemetry (e.g. via cost aggregators), we need access to the rich raw metadata structure returned by these providers.

Changes Made

  • src/pipecat/metrics/metrics.py: Added an optional raw_usage_metadata dictionary field to the LLMTokenUsage schema.
  • src/pipecat/services/google/gemini_live/llm.py: Captured the complete usage_metadata object from the Gemini Live response (including modal details like TEXT, AUDIO, IMAGE, VIDEO, tools, and cache) and attached it under raw_usage_metadata.
  • src/pipecat/services/openai/realtime/llm.py: Captured and attached the full usage response payload from the OpenAI Realtime event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant