fix: correct Azure Responses API URL construction

- Fix URL construction to properly append API version query parameter
- Avoid concatenating baseUrl twice
This commit is contained in:
Roo Code 2025-09-23 15:49:34 +00:00
parent 49b42793da
commit 18fe5a450a

View file

@ -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, {