Make sure caller can get an OpenAI client from get_openai_client() with a custom http_client#45028
Merged
dargilco merged 4 commits intofeature/azure-ai-projects/2.0.0b4from Feb 5, 2026
Conversation
get_openai_client() with a custom http_client
sakoll
approved these changes
Feb 5, 2026
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
…4' into dargilco/fix-get-openai-client
…4' into dargilco/fix-get-openai-client
c69cb98
into
feature/azure-ai-projects/2.0.0b4
18 of 21 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current implementation: The method
get_openai_client()implemented console logging of OpenAI client network calls, by using a customhttpx.Client(from the httpx package). This happens if you define the environment variableAZURE_AI_PROJECTS_CONSOLE_LOGGING=true. This http client is passed into the constructor of the OpenAI client by setting the input argumenthttp_client. If the environment variable is not defined (or does not have a value "true") we pass inhttp_client=Noneto the OpenAI client constructor.The problem with this implementation: It prevents the caller from defining their how
http_clientand passing it into theget_openai_client()method, with the intention that that keyword argument will be passed into the OpenAI client constructor (as the doc string suggests).The fix is to make sure that if the logging environment variable is not defined, which is the common case, and the caller supplied their own "http_client", we pass it as-is to the constructor of the OpenAI client.
Add a test for this for the sync and async versions.
Thank you Sashank for calling out this bug!