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
1
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 (
...
@@ -9,6 +9,7 @@ import (
"mime/multipart"
"mime/multipart"
"net/http"
"net/http"
"net/textproto"
"net/textproto"
"one-api/common"
"one-api/constant"
"one-api/constant"
"one-api/dto"
"one-api/dto"
"one-api/relay/channel"
"one-api/relay/channel"
...
@@ -172,6 +173,23 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
...
@@ -172,6 +173,23 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if
len
(
request
.
Usage
)
==
0
{
if
len
(
request
.
Usage
)
==
0
{
request
.
Usage
=
json
.
RawMessage
(
`{"include":true}`
)
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
strings
.
HasPrefix
(
request
.
Model
,
"o"
)
{
if
request
.
MaxCompletionTokens
==
0
&&
request
.
MaxTokens
!=
0
{
if
request
.
MaxCompletionTokens
==
0
&&
request
.
MaxTokens
!=
0
{
...
...
ccran
@ccran
mentioned in commit
7c044d7c
Sep 14, 2026
mentioned in commit
7c044d7c
mentioned in commit 7c044d7c5c2d2beadf16b21910950f8f593bc3ef
Toggle commit list
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