aiproxy支持vip地址(配置渠道时在key后加上 #vip 后缀)
This commit is contained in:
parent
076ec68989
commit
e54abc0f89
@ -9,6 +9,7 @@ import (
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Adaptor struct {
|
||||
@ -20,12 +21,18 @@ func (a *Adaptor) Init(meta *meta.Meta) {
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
||||
return fmt.Sprintf("%s/api/library/ask", meta.BaseURL), nil
|
||||
baseURL := meta.BaseURL
|
||||
if strings.HasSuffix(meta.APIKey, "#vip") {
|
||||
baseURL = "https://apivip.aiproxy.io"
|
||||
}
|
||||
return fmt.Sprintf("%s/api/library/ask", baseURL), nil
|
||||
}
|
||||
|
||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {
|
||||
adaptor.SetupCommonRequestHeader(c, req, meta)
|
||||
req.Header.Set("Authorization", "Bearer "+meta.APIKey)
|
||||
apiKey := meta.APIKey
|
||||
apiKey = strings.TrimSuffix(apiKey, "#vip")
|
||||
req.Header.Set("Authorization", "Bearer "+apiKey)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
@ -51,6 +51,4 @@ var ImagePromptLengthLimitations = map[string]int{
|
||||
}
|
||||
|
||||
var ImageOriginModelName = map[string]string{
|
||||
"ali-stable-diffusion-xl": "stable-diffusion-xl",
|
||||
"ali-stable-diffusion-v1.5": "stable-diffusion-v1.5",
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user