Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(azure): azure_deployment use with realtime + non-deployment-based APIs #2154

Merged
merged 12 commits into from
Feb 28, 2025

Conversation

kristapratico
Copy link
Contributor

@kristapratico kristapratico commented Feb 27, 2025

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Resolves #2120 and #1397

When the Azure client is initialized with both azure_endpoint and azure_deployment, the azure_deployment is added to the base_url:

if azure_deployment is not None:
base_url = f"{azure_endpoint.rstrip('/')}/openai/deployments/{azure_deployment}"

Having the deployment hardcoded in the base_url can be problematic when a non-deployments API is called, or with the realtime API (which puts the deployment in the query params instead of URL path). This PR overrides _prepare_url to use the original azure_endpoint passed in with cases where a non-deployment based API is being called (or realtime). It also removes the model query param from the realtime URL (it's not expected for Azure).

Additional context & links

@kristapratico kristapratico requested a review from a team as a code owner February 27, 2025 22:58
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me, thanks!

@RobertCraigie RobertCraigie changed the title (azure) fix azure_deployment use with realtime + non-deployment-based APIs fix(azure): azure_deployment use with realtime + non-deployment-based APIs Feb 28, 2025
@RobertCraigie RobertCraigie changed the base branch from main to next February 28, 2025 14:30
@RobertCraigie RobertCraigie merged commit 5846b55 into openai:next Feb 28, 2025
2 checks passed
@stainless-app stainless-app bot mentioned this pull request Feb 28, 2025
stainless-app bot pushed a commit that referenced this pull request Mar 1, 2025
… APIs (#2154)

* support realtime with azure_deployment

* lint

* use rsplit

* switch approach: save copy of the original url

* save azure_endpoint as it was given

* docstring

* format

* remove unnecessary check + add test

* fix for websocket_base_url

* add another test
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Realtime API URL is generated wrong based on a endpoint
2 participants