Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

@azure/openai - Additional OPTIONS request made before POST request for getChatCompletions call #29572

Open
2 of 6 tasks
jamesmcroft opened this issue May 3, 2024 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@jamesmcroft
Copy link

  • Package Name: @azure/openai
  • Package Version: 1.0.0-beta.12
  • Operating system: Windows 11
  • nodejs
    • version: 20.12.1
  • browser
    • name/version:
  • typescript
    • version: 5.4.2
  • Is the bug related to documentation in

Describe the bug
A clear and concise description of what the bug is.

When calling the getChatCompletions function of an OpenAIClient, an OPTIONS call to the API is made before the POST call is successfully processed.

For most scenarios calling Azure OpenAI directly, this works fine. However, scenarios that implement proxies to multiple Azure OpenAI backend instances do not. This is because the OPTIONS request is not defined in the OpenAPI specification for the Azure OpenAI APIs. Those implementing the spec will not handle OPTIONS requests as is not expected.

Exploring the JS SDK, I cannot find where this request is being made as it is not clear in the OpenAI specific source that this is the case.

To confirm functionality across Azure OpenAI SDKs, the .NET SDK will only perform the POST request resulting in a successful response via a proxy.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new OpenAIClient with default Azure OpenAI configuration
  2. Using a traffic monitoring tool (such as Fiddler), make a request using the OpenAIClient using the getChatCompletions function.

Notice that there are two requests made. The initial OPTIONS request, and the subsequent POST request.

Expected behavior
A clear and concise description of what you expected to happen.

Only the POST request should be made.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. labels May 3, 2024
Copy link

github-actions bot commented May 3, 2024

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @glharper.

@jamesmcroft
Copy link
Author

Attempting to hijack the requests with a custom HttpClient implementation from the @azure/core-rest-pipeline library also does not work as expected.

I can assume that the OPTIONS request is part of a downstream function called by the default HTTP client provided by the core-rest-pipeline SDK.

@xirzec
Copy link
Member

xirzec commented May 3, 2024

@jamesmcroft this is odd, I don't think we should be making OPTIONS requests in Node. I'd expect this to only happen in a browser due to CORS. Can you confirm the environment you're executing your code in is Node 20?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants