|
|
@@ -196,8 +196,8 @@ func TokenAuth() func(c *gin.Context) {
|
|
|
}
|
|
|
c.Request.Header.Set("Authorization", "Bearer "+key)
|
|
|
}
|
|
|
- // 检查path是 /v1/messages (Claude API)
|
|
|
- if strings.HasPrefix(c.Request.URL.Path, "/v1/messages") {
|
|
|
+ // 检查path包含/v1/messages 或 /v1/models
|
|
|
+ if strings.Contains(c.Request.URL.Path, "/v1/messages") || strings.Contains(c.Request.URL.Path, "/v1/models") {
|
|
|
anthropicKey := c.Request.Header.Get("x-api-key")
|
|
|
if anthropicKey != "" {
|
|
|
c.Request.Header.Set("Authorization", "Bearer "+anthropicKey)
|
|
|
@@ -205,10 +205,8 @@ func TokenAuth() func(c *gin.Context) {
|
|
|
}
|
|
|
// gemini api 从query中获取key
|
|
|
if strings.HasPrefix(c.Request.URL.Path, "/v1beta/models") ||
|
|
|
- strings.HasPrefix(c.Request.URL.Path, "/v1beta/files") ||
|
|
|
- strings.HasPrefix(c.Request.URL.Path, "/upload/v1beta/files") ||
|
|
|
strings.HasPrefix(c.Request.URL.Path, "/v1beta/openai/models") ||
|
|
|
- strings.HasPrefix(c.Request.URL.Path, "/v1/models") {
|
|
|
+ strings.HasPrefix(c.Request.URL.Path, "/v1/models/") {
|
|
|
skKey := c.Query("key")
|
|
|
if skKey != "" {
|
|
|
c.Request.Header.Set("Authorization", "Bearer "+skKey)
|