Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b8d5b223
authored
Nov 20, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: When retrieving the model list with multiple keys, select the first enabled one.
parent
ab02dc26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletions
+11
-1
controller/channel.go
+11
-1
No files found.
controller/channel.go
View file @
b8d5b223
...
...
@@ -203,9 +203,19 @@ func FetchUpstreamModels(c *gin.Context) {
url
=
fmt
.
Sprintf
(
"%s/v1/models"
,
baseURL
)
}
// 获取用于请求的可用密钥(多密钥渠道优先使用启用状态的密钥)
key
,
_
,
apiErr
:=
channel
.
GetNextEnabledKey
()
if
apiErr
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
fmt
.
Sprintf
(
"获取渠道密钥失败: %s"
,
apiErr
.
Error
()),
})
return
}
key
=
strings
.
TrimSpace
(
key
)
// 获取响应体 - 根据渠道类型决定是否添加 AuthHeader
var
body
[]
byte
key
:=
strings
.
Split
(
channel
.
Key
,
"
\n
"
)[
0
]
switch
channel
.
Type
{
case
constant
.
ChannelTypeAnthropic
:
body
,
err
=
GetResponseBody
(
"GET"
,
url
,
channel
,
GetClaudeAuthHeader
(
key
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment