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
8df5a458
authored
Aug 11, 2025
by
duyazhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add responses support for cloudflare
parent
67eb7315
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
relay/channel/cloudflare/adaptor.go
+10
-2
No files found.
relay/channel/cloudflare/adaptor.go
View file @
8df5a458
...
...
@@ -8,6 +8,7 @@ import (
"net/http"
"one-api/dto"
"one-api/relay/channel"
"one-api/relay/channel/openai"
relaycommon
"one-api/relay/common"
"one-api/relay/constant"
"one-api/types"
...
...
@@ -33,6 +34,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
return
fmt
.
Sprintf
(
"%s/client/v4/accounts/%s/ai/v1/chat/completions"
,
info
.
BaseUrl
,
info
.
ApiVersion
),
nil
case
constant
.
RelayModeEmbeddings
:
return
fmt
.
Sprintf
(
"%s/client/v4/accounts/%s/ai/v1/embeddings"
,
info
.
BaseUrl
,
info
.
ApiVersion
),
nil
case
constant
.
RelayModeResponses
:
return
fmt
.
Sprintf
(
"%s/client/v4/accounts/%s/ai/v1/responses"
,
info
.
BaseUrl
,
info
.
ApiVersion
),
nil
default
:
return
fmt
.
Sprintf
(
"%s/client/v4/accounts/%s/ai/run/%s"
,
info
.
BaseUrl
,
info
.
ApiVersion
,
info
.
UpstreamModelName
),
nil
}
...
...
@@ -57,8 +60,7 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
}
func
(
a
*
Adaptor
)
ConvertOpenAIResponsesRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
OpenAIResponsesRequest
)
(
any
,
error
)
{
// TODO implement me
return
nil
,
errors
.
New
(
"not implemented"
)
return
request
,
nil
}
func
(
a
*
Adaptor
)
DoRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
requestBody
io
.
Reader
)
(
any
,
error
)
{
...
...
@@ -105,6 +107,12 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom
}
else
{
err
,
usage
=
cfHandler
(
c
,
info
,
resp
)
}
case
constant
.
RelayModeResponses
:
if
info
.
IsStream
{
usage
,
err
=
openai
.
OaiResponsesStreamHandler
(
c
,
info
,
resp
)
}
else
{
usage
,
err
=
openai
.
OaiResponsesHandler
(
c
,
info
,
resp
)
}
case
constant
.
RelayModeAudioTranslation
:
fallthrough
case
constant
.
RelayModeAudioTranscription
:
...
...
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