You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is an issue with the Python library and not an underlying OpenAI API
This is an issue with the Python library
Describe the bug
When passing a custom http client to the OpenAI client, it does not properly use the custom client's auth flow.
In the client's _request method, self.custom_auth is passed to self._client.send (link to source code).
The property custom_auth however is simply defined as return None (link to source code).
Because we explicitly pass None to the auth argument of the send method of the httpx client, the client doesn't use the default value USE_CLIENT_DEFAULT for the auth argument (link to source code).
Is there a reason why we have this custom_auth property on the client? If we do not pass it to the auth argument of self._client.send, everything works as expected and the auth logic of the custom httpx client is properly invoked.
To Reproduce
openai_client=OpenAI(
api_key="<API_KEY>",
base_url="<BASE_URL>",
http_client="<HTTP_CLIENT>",
)
completion=openai_client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Last name of the president of the United States",
}
],
model="gpt-3.5-turbo",
) # Does not invoke the authentication flow of the client passed using `http_client`.
Code snippets
No response
OS
MacOS 14.2
Python version
3.11.6
Library version
1.3.9
The text was updated successfully, but these errors were encountered:
TomSteenbergen
changed the title
Authentication of custom http client not used when making a request
Auth flow of custom http client not invoked when making a request
Dec 27, 2023
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
When passing a custom http client to the OpenAI client, it does not properly use the custom client's auth flow.
In the client's
_request
method,self.custom_auth
is passed toself._client.send
(link to source code).The property
custom_auth
however is simply defined asreturn None
(link to source code).Because we explicitly pass
None
to theauth
argument of thesend
method of thehttpx
client, the client doesn't use the default valueUSE_CLIENT_DEFAULT
for theauth
argument (link to source code).Is there a reason why we have this
custom_auth
property on the client? If we do not pass it to theauth
argument ofself._client.send
, everything works as expected and the auth logic of the customhttpx
client is properly invoked.To Reproduce
Code snippets
No response
OS
MacOS 14.2
Python version
3.11.6
Library version
1.3.9
The text was updated successfully, but these errors were encountered: