Set User-Agent in OpenAI client requests#44666
Closed
jayesh-tanna wants to merge 6 commits intoAzure:mainfrom
Closed
Set User-Agent in OpenAI client requests#44666jayesh-tanna wants to merge 6 commits intoAzure:mainfrom
jayesh-tanna wants to merge 6 commits intoAzure:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds User-Agent header support to OpenAI client requests in the Azure AI Projects SDK. The User-Agent value defaults to "AIProjectClient/Python" and can be customized at the AIProjectClient level or via the get_openai_client method's default_headers parameter. The implementation ensures all OpenAI requests include the SDK identifier for backend telemetry tracking.
Changes:
- Updated
USER_AGENT_APP_IDfrom "AIProjectClient" to "AIProjectClient/Python" in_patch_user_agentfunction - Added User-Agent header configuration in the sync
get_openai_clientmethod - Updated docstring to document the automatic User-Agent header inclusion
howieleung
reviewed
Jan 16, 2026
PratibhaShrivastav18
approved these changes
Jan 16, 2026
howieleung
approved these changes
Jan 20, 2026
howieleung
requested changes
Jan 20, 2026
Member
howieleung
left a comment
There was a problem hiding this comment.
Your change replace the existing user agent header of OpenAI client. You should append. Not replace.
Member
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.
Description
This PR adds User-Agent header support to OpenAI client requests. The User-Agent value is set to "AIProjectClient/Python" by default. Users can customize the User-Agent at two levels:
(1) At AIProjectClient level using the user_agent parameter: AIProjectClient(endpoint="...", credential=credential, user_agent="MyApp"), which results in "MyApp-AIProjectClient/Python-{VERSION}",
(2) At get_openai_client level using default_headers: client.get_openai_client(default_headers={"User-Agent": "DifferentApp"}), which results in "DifferentApp-AIProjectClient/Python-{VERSION}".
If neither is provided, the default "AIProjectClient/Python-{VERSION}" is used. This ensures all OpenAI requests include the SDK identifier for backend telemetry tracking.
If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines