fix: preserve URL query params for Azure OpenAI and custom endpoints#8766
Closed
pein892 wants to merge 1 commit into
Closed
fix: preserve URL query params for Azure OpenAI and custom endpoints#8766pein892 wants to merge 1 commit into
pein892 wants to merge 1 commit into
Conversation
Azure OpenAI requires an `api-version` query parameter on every request. When users include it in the base_url (e.g. `?api-version=2025-04-01-preview`), the OpenAI SDK silently drops it during URL construction, causing 404 errors. Extract query params from base_url and pass them via `default_query` so the SDK appends them to every request. This is a generic solution that works for any custom endpoint requiring query parameters, not just Azure. No-op for URLs without query params — fully backward compatible.
Contributor
|
Merged via #15845 along with the other open Azure PRs as one consolidated salvage + an auto-detection feature on top (URL sniff + Your commits were cherry-picked with authorship preserved ( |
3 tasks
Collaborator
This was referenced Apr 26, 2026
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.
Problem
Azure OpenAI endpoints require an
api-versionquery parameter on every API request. When users configure this inbase_url(e.g.https://resource.openai.azure.com/openai?api-version=2025-04-01-preview), the OpenAI Python SDK silently drops query parameters during URL construction, resulting in HTTP 404 errors.This is the same class of issue as #4599 (Azure Anthropic), but affecting the OpenAI SDK path used by custom providers.
Root Cause
The OpenAI SDK stores
base_urlas anhttpx.URLand joins API paths (e.g./responses,/chat/completions) onto it. During this join, any query parameters in the original URL are discarded — Azure never receivesapi-versionand returns 404.Fix
Extract query parameters from
base_urlbefore passing it to the OpenAI SDK, and forward them via the SDK'sdefault_queryparameter. This ensures they are appended to every outgoing request.Files changed:
run_agent.py— main agent client creationagent/auxiliary_client.py— auxiliary client creation (added_extract_url_query_params()helper, applied to all custom endpoint paths)Backward Compatibility
default_queryisNone, original behavior unchangedExample Configuration
Test Plan
api-versionin base_url returns successful responses