Conversation
- Add AudioChatQuery, AudioChatResult, AudioChatStreamResult models - Implement audioChats() and audioChatsStream() methods - Add type-safe enums: AudioFormat, Voice, Modality - Add AudioConversationManager for multi-turn conversations - Add support for gpt-4o-realtime-preview and gpt-4o-mini-realtime-preview models - Add dated variants: 2024-12-17 snapshots - Comprehensive test coverage (38 tests across 4 test suites) - Update README with audio chat documentation and examples - Format requirements: wav/mp3 for input, pcm16 recommended for streaming output - Relaxed parsing support for handling missing fields
7d5804b to
7d385dd
Compare
Krivoblotsky
left a comment
There was a problem hiding this comment.
Thank you for the work here, and apologies for the wait. It merges cleanly with main, builds, and all 217 tests pass. I want to be upfront about the direction, because it affects most of the diff.
ChatQuery already covers audio chat. On main today: ChatQuery.modalities, ChatQuery.audioOptions (11 voices including ash, ballad, coral, sage, verse; formats mp3, opus, flac, wav, pcm16), ContentPartAudioParam for input_audio, ChatResult.Choice.Message.audio (id, expiresAt, data, transcript) and the same on the streaming delta. AudioChatQuery, AudioChatResult and AudioChatStreamResult are a second way to call /chat/completions with a smaller surface (6 voices, fewer parameters), and audioChats / audioChatsStream add four protocol requirements, which the new API-breakage gate flags. The library should have one way to do a chat completion.
AudioConversationManager is conversation state management, which belongs in the app (or the Demo), not in the SDK.
What we would like to take from this PR:
- the
gpt-audio-1.5constant (plusgpt-audioandgpt-audio-mini), withgpt-4o-audio-previewmarked deprecated since it was shut down on 7 May 2026; - a README section "Audio input and output with Chat Completions" built on
ChatQuery, which the README lacks entirely today; your examples adapt almost one to one; - the coding tests, adapted to
ChatQuerywhere they add coverage we do not have.
If you are up for reshaping the PR along those lines, that would be great and it would land quickly. If not, we can open a smaller PR that carries those pieces with you credited as co-author. Either way, thank you for pushing on audio support.
Hey, thanks for the feedback, I'll reshape it in the next couple days |
Summary
This PR implements audio-to-audio chat completion support, replacing the traditional STT→Chat→TTS pipeline with a single API call for 2-3x faster response times.
Supports both
gpt-4o-audio-preview/gpt-4o-mini-audio-preview(preview models) and the newgpt-audio-1.5(recommended by OpenAI for best performance with improved instruction following, tool calling, and multilingual accuracy).Features
audioChats()andaudioChatsStream()methodsAudioFormat(wav, mp3, flac, opus, pcm16) andVoice(alloy, echo, fable, onyx, nova, shimmer)AsyncThrowingStreamImplementation Details
AudioChatQuery,AudioChatResult,AudioChatStreamResult.gpt_4o_audio_preview,.gpt_4o_mini_audio_preview,.gpt_audio_1_5OpenAIProtocol,OpenAIAsync, with Combine supportTesting
Files Changed
Documentation
Added comprehensive Audio Chat section to README.md including:
Breaking Changes
None - this is a purely additive change.
Related