feat: sync remaining channel and relay updates

This commit is contained in:
OpenClaw Task Bot
2026-04-27 08:56:38 +08:00
parent 0321101ff7
commit 58c0258362
18 changed files with 465 additions and 271 deletions

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/relay/channel"
relaycommon "github.com/QuantumNous/new-api/relay/common"
@@ -81,7 +82,12 @@ func CommonClaudeHeadersOperation(c *gin.Context, req *http.Header, info *relayc
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {
channel.SetupApiRequestHeader(info, c, req)
req.Set("x-api-key", info.ApiKey)
if info.ChannelType == constant.ChannelTypeClaudeCodeCLIProxy {
req.Set("Authorization", "Bearer "+info.ApiKey)
req.Set("x-api-key", info.ApiKey)
} else {
req.Set("x-api-key", info.ApiKey)
}
anthropicVersion := c.Request.Header.Get("anthropic-version")
if anthropicVersion == "" {
anthropicVersion = "2023-06-01"

View File

@@ -301,24 +301,27 @@ func (info *RelayInfo) ToString() string {
// 定义支持流式选项的通道类型
var streamSupportedChannels = map[int]bool{
constant.ChannelTypeOpenAI: true,
constant.ChannelTypeAnthropic: true,
constant.ChannelTypeAws: true,
constant.ChannelTypeGemini: true,
constant.ChannelCloudflare: true,
constant.ChannelTypeAzure: true,
constant.ChannelTypeVolcEngine: true,
constant.ChannelTypeOllama: true,
constant.ChannelTypeXai: true,
constant.ChannelTypeDeepSeek: true,
constant.ChannelTypeBaiduV2: true,
constant.ChannelTypeZhipu_v4: true,
constant.ChannelTypeAli: true,
constant.ChannelTypeSubmodel: true,
constant.ChannelTypeCodex: true,
constant.ChannelTypeMoonshot: true,
constant.ChannelTypeMiniMax: true,
constant.ChannelTypeSiliconFlow: true,
constant.ChannelTypeOpenAI: true,
constant.ChannelTypeCodexCLIProxy: true,
constant.ChannelTypeGeminiCLIProxy: true,
constant.ChannelTypeAnthropic: true,
constant.ChannelTypeClaudeCodeCLIProxy: true,
constant.ChannelTypeAws: true,
constant.ChannelTypeGemini: true,
constant.ChannelCloudflare: true,
constant.ChannelTypeAzure: true,
constant.ChannelTypeVolcEngine: true,
constant.ChannelTypeOllama: true,
constant.ChannelTypeXai: true,
constant.ChannelTypeDeepSeek: true,
constant.ChannelTypeBaiduV2: true,
constant.ChannelTypeZhipu_v4: true,
constant.ChannelTypeAli: true,
constant.ChannelTypeSubmodel: true,
constant.ChannelTypeCodex: true,
constant.ChannelTypeMoonshot: true,
constant.ChannelTypeMiniMax: true,
constant.ChannelTypeSiliconFlow: true,
}
func GenRelayInfoWs(c *gin.Context, ws *websocket.Conn) *RelayInfo {

View File

@@ -33,6 +33,15 @@ func GetFullRequestURL(baseURL string, requestURL string, channelType int) strin
fullRequestURL = fmt.Sprintf("%s%s", baseURL, strings.TrimPrefix(requestURL, "/openai/deployments"))
}
}
if channelType == constant.ChannelTypeCodexCLIProxy ||
channelType == constant.ChannelTypeGeminiCLIProxy {
trimmedRequestURL := strings.TrimPrefix(requestURL, "/v1")
if trimmedRequestURL == "" {
trimmedRequestURL = "/"
}
fullRequestURL = fmt.Sprintf("%s%s", baseURL, trimmedRequestURL)
}
return fullRequestURL
}