Skip to content

Conversation

@lion8
Copy link
Contributor

@lion8 lion8 commented Dec 3, 2025

Summary

Add the usage field to conversationItemInputAudioTranscriptionCompletedEventSchema and InputAudioTranscriptionCompletedEvent to expose token usage information for audio transcriptions.

Problem

The OpenAI Realtime API includes a usage field in the conversation.item.input_audio_transcription.completed event containing token usage information:

{
  "type": "conversation.item.input_audio_transcription.completed",
  "event_id": "event_XX",
  "item_id": "item_XX",
  "content_index": 0,
  "transcript": "Hey, can you hear me?",
  "usage": {
    "type": "tokens",
    "total_tokens": 22,
    "input_tokens": 13,
    "input_token_details": {
      "text_tokens": 0,
      "audio_tokens": 13
    },
    "output_tokens": 9
  }
}

However, the SDK schema did not include this field. Since Zod schemas use .strip() mode by default, the usage field was silently removed during parsing, making it inaccessible to developers.

Solution

  • Added usage field to the Zod schema in openaiRealtimeEvents.ts
  • Added usage type to InputAudioTranscriptionCompletedEvent in transportLayerEvents.ts

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: dfb2976

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@openai/agents-realtime Patch
@openai/agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@seratch seratch added bug Something isn't working package:agents-realtime labels Dec 4, 2025
@seratch seratch added this to the 0.3.x milestone Dec 4, 2025
@seratch seratch merged commit 1300121 into openai:main Dec 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working package:agents-realtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants