fix(voice): refresh callable API keys before streamed STT - #4537
Closed
sylvesterkaczmarek wants to merge 3 commits into
Closed
fix(voice): refresh callable API keys before streamed STT#4537sylvesterkaczmarek wants to merge 3 commits into
sylvesterkaczmarek wants to merge 3 commits into
Conversation
Member
|
Thanks for the contribution. Callable API keys do need to be refreshed before the manual streamed-STT WebSocket handshake, and the regression test captures the relevant failure. However, #4532 is already changing the same handshake and its current review requires this refresh behavior. Please move the refresh helper and test into #4532, using the shared OpenAI-client WebSocket utility there, and close #4537 so this connection path is corrected in one PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refresh callable or rotating
AsyncOpenAIAPI keys before opening the streamed STT WebSocket connection.The OpenAI Python client supports API-key providers and refreshes them before normal requests. Streamed STT opens its WebSocket manually, however, and currently reads
client.api_keydirectly for theAuthorizationheader without invoking the client's refresh hook first. With a callable key provider, that can send the initial empty/stale key instead of the current credential.The Responses WebSocket transport in this SDK already performs the same refresh before preparing its handshake.
Fix
Test plan
Added a focused regression with a rotating client whose initial API key is empty and whose refresh hook installs a new key. The test verifies that:
Authorizationheader contains the refreshed keyThe branch is based directly on current
mainat7e55afc9500d12937687988f1e91e900dcb4ad09and is 0 commits behind it. The production change is limited to the refresh helper and one pre-handshake call.Risk
Low. Static API keys behave as before. The additional work only occurs when the supplied OpenAI client exposes the refresh hook used for dynamic credentials.
Issue number
None. Found while auditing streamed STT parity with the existing Responses WebSocket authentication path.