From 18fe5a450af436be49e9d09478fdfbc33dd08680 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 23 Sep 2025 15:49:34 +0000 Subject: [PATCH] fix: correct Azure Responses API URL construction - Fix URL construction to properly append API version query parameter - Avoid concatenating baseUrl twice --- src/api/providers/openai-native.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/api/providers/openai-native.ts b/src/api/providers/openai-native.ts index f9de884fac..ce70a1a0b2 100644 --- a/src/api/providers/openai-native.ts +++ b/src/api/providers/openai-native.ts @@ -475,10 +475,17 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio const apiKey = this.options.openAiNativeApiKey ?? "not-provided" const baseUrl = this.options.openAiNativeBaseUrl || "https://api.openai.com" - // For Azure Responses API, the URL is already complete - const url = this.isAzureResponsesApi - ? `${baseUrl}${this.options.azureApiVersion ? `${baseUrl.includes("?") ? "&" : "?"}api-version=${this.options.azureApiVersion}` : ""}` - : `${baseUrl}/v1/responses` + // For Azure Responses API, the URL is already complete, just add API version if provided + let url: string + if (this.isAzureResponsesApi) { + url = baseUrl + if (this.options.azureApiVersion) { + const separator = baseUrl.includes("?") ? "&" : "?" + url = `${baseUrl}${separator}api-version=${this.options.azureApiVersion}` + } + } else { + url = `${baseUrl}/v1/responses` + } try { const response = await fetch(url, {