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
3a5618ed
authored
Jun 25, 2025
by
t0ng7u
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/alpha' into alpha
parents
70a4b576
04d525e3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
3 deletions
+4
-3
middleware/auth.go
+1
-1
middleware/distributor.go
+1
-1
relay/constant/relay_mode.go
+1
-1
router/relay-router.go
+1
-0
No files found.
middleware/auth.go
View file @
3a5618ed
...
...
@@ -184,7 +184,7 @@ func TokenAuth() func(c *gin.Context) {
}
}
// gemini api 从query中获取key
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1beta/models/"
)
{
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1beta/models/"
)
||
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/models/"
)
{
skKey
:=
c
.
Query
(
"key"
)
if
skKey
!=
""
{
c
.
Request
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
skKey
)
...
...
middleware/distributor.go
View file @
3a5618ed
...
...
@@ -179,7 +179,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
}
c
.
Set
(
"platform"
,
string
(
constant
.
TaskPlatformKling
))
c
.
Set
(
"relay_mode"
,
relayMode
)
}
else
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1beta/models/"
)
{
}
else
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1beta/models/"
)
||
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/models/"
)
{
// Gemini API 路径处理: /v1beta/models/gemini-2.0-flash:generateContent
relayMode
:=
relayconstant
.
RelayModeGemini
modelName
:=
extractModelNameFromGeminiPath
(
c
.
Request
.
URL
.
Path
)
...
...
relay/constant/relay_mode.go
View file @
3a5618ed
...
...
@@ -80,7 +80,7 @@ func Path2RelayMode(path string) int {
relayMode
=
RelayModeRerank
}
else
if
strings
.
HasPrefix
(
path
,
"/v1/realtime"
)
{
relayMode
=
RelayModeRealtime
}
else
if
strings
.
HasPrefix
(
path
,
"/v1beta/models"
)
{
}
else
if
strings
.
HasPrefix
(
path
,
"/v1beta/models"
)
||
strings
.
HasPrefix
(
path
,
"/v1/models"
)
{
relayMode
=
RelayModeGemini
}
return
relayMode
...
...
router/relay-router.go
View file @
3a5618ed
...
...
@@ -63,6 +63,7 @@ func SetRelayRouter(router *gin.Engine) {
httpRouter
.
DELETE
(
"/models/:model"
,
controller
.
RelayNotImplemented
)
httpRouter
.
POST
(
"/moderations"
,
controller
.
Relay
)
httpRouter
.
POST
(
"/rerank"
,
controller
.
Relay
)
httpRouter
.
POST
(
"/models/*path"
,
controller
.
Relay
)
}
relayMjRouter
:=
router
.
Group
(
"/mj"
)
...
...
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