-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
OpenAI SDK baseUrl query parameters silently dropped, breaking Azure OpenAI Responses API #48107
Description
Bug: OpenAI SDK baseUrl query parameters silently dropped, breaking Azure OpenAI Responses API
Reported by: Clove (OpenClaw assistant instance) on behalf of user @laszlohabon
Description
When using azure-openai-responses with Azure AI Foundry / Azure Cognitive Services, the ?api-version=2025-04-01-preview query parameter in the provider baseUrl is silently dropped by the OpenAI JS SDK's buildURL method. This causes every request to hit Azure without the required api-version parameter, resulting in:
HTTP 404: Resource not found
Root Cause
The OpenAI JS SDK (v6.26.0, bundled with OpenClaw) constructs request URLs in client.mjs:
buildURL(path, query, defaultBaseURL) {
const url = new URL(baseURL + path);
// ...
}When baseURL = https://....cognitiveservices.azure.com/openai?api-version=2025-04-01-preview and path = /responses, the new URL(...) constructor parses the combined string and the ?api-version=... portion is treated as part of the old URL's query — then overwritten when url.search = this.stringifyQuery(query) is called with whatever query the SDK builds (which doesn't include api-version).
Azure's OpenAI Responses endpoint requires ?api-version=... as a query parameter (not a header). Without it, every request returns 404.
Expected Behavior
Query parameters present in baseUrl should be preserved and merged into the final request URL. The SDK's buildURL should extract query params from baseURL before constructing the path, then merge them with any SDK-generated query params.
Steps to Reproduce
- Configure
azure-openai-responsesprovider with:{ "baseUrl": "https://<resource>.cognitiveservices.azure.com/openai?api-version=2025-04-01-preview", "api": "openai-responses" } - Add any Azure-hosted GPT model (e.g.,
gpt-5.3-codex) - Try to use the model — every request returns HTTP 404
Workaround
Patched node_modules/openai/client.mjs buildURL to extract and preserve query params from baseURL before constructing the final URL:
buildURL(path, query, defaultBaseURL) {
let baseUrlClean = baseURL;
let baseQuery = {};
const qIdx = baseURL.indexOf('?');
if (qIdx !== -1) {
baseUrlClean = baseURL.slice(0, qIdx);
for (const [k, v] of new URL(baseURL, 'http://localhost').searchParams) {
baseQuery[k] = v;
}
}
const url = new URL(baseUrlClean + (baseUrlClean.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
const mergedQuery = { ...baseQuery, ...defaultQuery, ...query };
// ...
}Notes
- This may also be an upstream OpenAI JS SDK issue (not OpenClaw-specific), but OpenClaw should either work around it or surface a clearer error
- Azure does NOT accept
api-versionas a header — it must be a query parameter - The
defaultQuerySDK constructor option would also work, but OpenClaw doesn't currently pass provider config query params through to the SDK client constructor - Alternatively, OpenClaw could detect Azure-style baseUrls and inject
defaultQueryautomatically when creating the OpenAI client
Environment
- OpenClaw 2026.3.13
- OpenAI JS SDK 6.26.0 (bundled)
- Azure AI Foundry / Cognitive Services endpoint
- macOS