aiproxy支持vip地址(配置渠道时在key后加上 #vip 后缀)

This commit is contained in:
mlkt
2024-05-26 05:57:05 +08:00
parent 076ec68989
commit e54abc0f89
3 changed files with 19 additions and 5 deletions

View File

@@ -48,6 +48,11 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
return minimax.GetRequestURL(meta)
case channeltype.Doubao:
return doubao.GetRequestURL(meta)
case channeltype.AIProxy:
if strings.HasSuffix(meta.APIKey, "#vip") {
return GetFullRequestURL("https://apivip.aiproxy.io", meta.RequestURLPath, meta.ChannelType), nil
}
fallthrough
default:
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
}
@@ -59,7 +64,11 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *me
req.Header.Set("api-key", meta.APIKey)
return nil
}
req.Header.Set("Authorization", "Bearer "+meta.APIKey)
apiKey := meta.APIKey
if meta.ChannelType == channeltype.AIProxy {
apiKey = strings.TrimSuffix(apiKey, "#vip")
}
req.Header.Set("Authorization", "Bearer "+apiKey)
if meta.ChannelType == channeltype.OpenRouter {
req.Header.Set("HTTP-Referer", "https://github.com/songquanpeng/one-api")
req.Header.Set("X-Title", "One API")