From 3ab65a822174d1c984c61fa1a6f45feaee80ae56 Mon Sep 17 00:00:00 2001 From: woan1136 Date: Mon, 13 Apr 2026 15:23:38 +0800 Subject: [PATCH] fix: add Azure channel support for /v1/responses/compact URL routing (#4149) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 --- relay/channel/openai/adaptor.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/relay/channel/openai/adaptor.go b/relay/channel/openai/adaptor.go index 2b7f71d6..56a58f28 100644 --- a/relay/channel/openai/adaptor.go +++ b/relay/channel/openai/adaptor.go @@ -136,8 +136,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { task = "chat/completions" + task } - // 特殊处理 responses API - if info.RelayMode == relayconstant.RelayModeResponses { + // 特殊处理 responses API(包含 compact) + if info.RelayMode == relayconstant.RelayModeResponses || info.RelayMode == relayconstant.RelayModeResponsesCompact { responsesApiVersion := "preview" subUrl := "/openai/v1/responses" @@ -150,6 +150,11 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { responsesApiVersion = info.ChannelOtherSettings.AzureResponsesVersion } + // compact 模式追加 /compact + if info.RelayMode == relayconstant.RelayModeResponsesCompact { + subUrl = subUrl + "/compact" + } + requestURL = fmt.Sprintf("%s?api-version=%s", subUrl, responsesApiVersion) return relaycommon.GetFullRequestURL(info.ChannelBaseUrl, requestURL, info.ChannelType), nil }