-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Set User-Agent in OpenAI client requests #44666
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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