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
94b68c2b
authored
Oct 10, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add sora video fetch task
parent
0d0e4f53
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
middleware/distributor.go
+3
-0
relay/channel/task/sora/adaptor.go
+7
-6
router/video-router.go
+1
-0
No files found.
middleware/distributor.go
View file @
94b68c2b
...
...
@@ -184,6 +184,9 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
modelRequest
.
Model
=
values
[
0
]
}
}
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
shouldSelectChannel
=
false
}
c
.
Set
(
"relay_mode"
,
relayMode
)
}
else
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/video/generations"
)
{
...
...
relay/channel/task/sora/adaptor.go
View file @
94b68c2b
...
...
@@ -32,12 +32,9 @@ type ImageURL struct {
URL
string
`json:"url"`
}
type
responsePayload
struct
{
ID
string
`json:"id"`
// task_id
}
type
responseTask
struct
{
ID
string
`json:"id"`
TaskID
string
`json:"task_id,omitempty"`
//兼容旧接口
Object
string
`json:"object"`
Model
string
`json:"model"`
Status
string
`json:"status"`
...
...
@@ -108,18 +105,22 @@ func (a *TaskAdaptor) DoResponse(c *gin.Context, resp *http.Response, _ *relayco
_
=
resp
.
Body
.
Close
()
// Parse Sora response
var
dResp
response
Payload
var
dResp
response
Task
if
err
:=
json
.
Unmarshal
(
responseBody
,
&
dResp
);
err
!=
nil
{
taskErr
=
service
.
TaskErrorWrapper
(
errors
.
Wrapf
(
err
,
"body: %s"
,
responseBody
),
"unmarshal_response_body_failed"
,
http
.
StatusInternalServerError
)
return
}
if
dResp
.
ID
==
""
{
if
dResp
.
TaskID
==
""
{
taskErr
=
service
.
TaskErrorWrapper
(
fmt
.
Errorf
(
"task_id is empty"
),
"invalid_response"
,
http
.
StatusInternalServerError
)
return
}
dResp
.
ID
=
dResp
.
TaskID
dResp
.
TaskID
=
""
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"task_id"
:
dResp
.
ID
}
)
c
.
JSON
(
http
.
StatusOK
,
dResp
)
return
dResp
.
ID
,
responseBody
,
nil
}
...
...
router/video-router.go
View file @
94b68c2b
...
...
@@ -19,6 +19,7 @@ func SetVideoRouter(router *gin.Engine) {
// docs: https://platform.openai.com/docs/api-reference/videos/create
{
videoV1Router
.
POST
(
"/videos"
,
controller
.
RelayTask
)
videoV1Router
.
GET
(
"/videos/:id"
,
controller
.
RelayTask
)
}
klingV1Router
:=
router
.
Group
(
"/kling/v1"
)
...
...
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