openai-python
openai-python copied to clipboard
fix(azure): remove unnecessary model parameter and require azure deployment
This PR addresses the reported issue with the Azure Realtime API URL generation (Issue #2120) by ensuring that the correct deployment value is used and by removing the unnecessary model query parameter. Previously, both the synchronous and asynchronous _configure_realtime methods included a model parameter that is not required by Azure, which could lead to confusion. With this update, only the deployment parameter is used, resulting in a cleaner and more accurate URL construction:
wss://<azure_endpoint>/openai/realtime?api-version=2024-10-01-preview&deployment=<azure_deployment>
Key Changes:
- Deployment Enforcement:
The code now raises aValueErrorif an azure_deployment is not provided, preventing misconfigurations. - Query Parameter Simplification:
The model parameter has been removed from the query dictionary in both _configure_realtime methods. Only the deployment parameter, taken fromself._azure_deployment, is now used. - Code Consistency:
Both synchronous and asynchronous methods now generate the URL consistently, matching the expected format for Azure realtime connections. - Verification:
Tests confirm that the URL is correctly generated when an azure_deployment is provided and that an error is raised if it is missing.
All tests have passed, so the fix is verified to work as intended. Please review the changes and let me know if you have any further feedback!
One question, afaik the query param for model isn't needed for azure, although the extra param doesn't cause a break, but not having to provide it to the connect method would be good!
One question, afaik the query param for model isn't needed for azure, although the extra param doesn't cause a break, but not having to provide it to the connect method would be good!
Hi @eavanvalkenburg, thanks for the suggestion. I've updated the PR to remove the unnecessary model query parameter from the _configure_realtime methods (both synchronous and asynchronous). Now, only the required deployment parameter is included when constructing the Azure realtime API URL.