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
4f6d16e3
authored
Aug 06, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add reasoning support for Openrouter requests with "-thinking" suffix
parent
f1faa08c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
relay/channel/openai/adaptor.go
+18
-0
No files found.
relay/channel/openai/adaptor.go
View file @
4f6d16e3
...
...
@@ -9,6 +9,7 @@ import (
"mime/multipart"
"net/http"
"net/textproto"
"one-api/common"
"one-api/constant"
"one-api/dto"
"one-api/relay/channel"
...
...
@@ -172,6 +173,23 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if
len
(
request
.
Usage
)
==
0
{
request
.
Usage
=
json
.
RawMessage
(
`{"include":true}`
)
}
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-thinking"
)
{
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-thinking"
)
request
.
Model
=
info
.
UpstreamModelName
if
len
(
request
.
Reasoning
)
==
0
{
reasoning
:=
map
[
string
]
any
{
"enabled"
:
true
,
}
if
request
.
ReasoningEffort
!=
""
{
reasoning
[
"effort"
]
=
request
.
ReasoningEffort
}
marshal
,
err
:=
common
.
Marshal
(
reasoning
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error marshalling reasoning: %w"
,
err
)
}
request
.
Reasoning
=
marshal
}
}
}
if
strings
.
HasPrefix
(
request
.
Model
,
"o"
)
{
if
request
.
MaxCompletionTokens
==
0
&&
request
.
MaxTokens
!=
0
{
...
...
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