Token Usage Logging
All voice-session components now emit a standardized token usage log when they stop. Use this to query spending perCommunicationId and provider across LLM, transcribers, and synthesizers.
Log shape
- Message:
Token usage summary - Level:
info - Fields (consistent for every component):
ComponentType:llm|transcriber|synthesizerProvider: provider slug (e.g.,openai,aws,deepgram,cartesia)Model: provider-specific model/voice identifier (e.g.,gpt-4.1,stt-rt-v3,aura-2-thalia-en)Component: fine-grained step (e.g.,summary,tags,sentiment,rate_call,identify_speakers,tts,stt,llm_realtime)TotalInputTokensTotalCachedInputTokensTotalOutputTokensInputAudioMinutes(transcribers) — precise input audio duration;TotalInputTokensis the ceiling of this value for parity with token fieldsOutputAudioMinutes(synthesizers) — precise output audio duration;TotalOutputTokensis the ceiling of this value for parity with token fields
- Context fields: base log entries already include
CommunicationId,TenantId, and component/function names vialogger.WithLogger.
Transcribers now emit input audio usage (InputAudioMinutes, withTotalInputTokens= ceil of minutes,TotalOutputTokens= transcript tokens). Synthesizers emit output audio usage (OutputAudioMinutes, withTotalOutputTokens= ceil of minutes).
Emission points
- OpenAI realtime LLM stop (
common/llm/openai/realtime.go). - Transcriber stops: AWS, Deepgram, Soniox, Speechmatics (
common/transcription/realtime/transcribers/*). - Synthesizer stops: Azure OpenAI, Cartesia, DeepDub, Deepgram, ElevenLabs, MiniMax (
wonderful-controller/components/synthesizer/providers/*). - Post-call enhancer steps (summary, tags, clarify, sentiment, rate call, identify speakers, issues) and rating helpers (
wonderful-controller/components/communications/service/enhancer.go,.../rater.go). - RAG sessions on dispose (
wonderful-controller/components/rags/service/session/logging_decorator.go) withComponent=ragand providergemini.
Implementation helper
Uselogger.LogTokenUsage(entry, componentType, provider, model, models.TokensUsage) from common/logger/token_usage.go to emit the log with the standard message and fields.
Query examples
- Tokens by provider:
"Token usage summary" @Provider:openai - Tokens for a call:
"Token usage summary" @CommunicationId:<comm-id>