-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
api-key missing from the request in case of async calls (AsyncOpenAI, AsyncAzureOpenAI) #1431
Comments
@SoranaBaciu I'm not able to reproduce this. Can you check that you don't have any environment variables set that might be interfering with the auth? |
@kristapratico no environment variables, actually seams to be ok for AsyncAzureOpenAI, issue appearing for AsyncOpenAI Here's my scipt
|
@SoranaBaciu based on your example, it looks like you're targeting the Azure OpenAI service through the AsyncOpenAI client. If you are using the Azure API, I recommend using the AsyncAzureOpenAI client since it's configured to work with Azure endpoints, auth, deployments, etc. To summarize,
Is there a reason you want to use AsyncOpenAI with Azure? |
@kristapratico No special reason. I wanted async support, and initially I've found AsyncOpenAI and discovered "the bug". Afterwards I've seen the dedicated class for Azure. |
Great. Krista is correct that |
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
When trying to perform an await AsyncOpenAI.chat.completions.create call, it will results in 'statusCode': 401, 'message': 'Unauthorized. Access token is missing.
The found workaround it to add extra_headers
After debugging I've seen that
_prepare_options
for sync calls (OpenAI, AzureOpenAI) is implemented, and it actually sets the api-key in the headers, while it is not for async chat completions (AsyncOpenAI, AsyncAzureOpenAI).To Reproduce
Library version 1.30.1
=>
Code snippets
No response
OS
Windows
Python version
3.11.2
Library version
1.30.1
The text was updated successfully, but these errors were encountered: