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
b7c0f754
authored
Mar 14, 2026
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add seedance2.0 video api
parent
a706f002
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
relay/channel/task/doubao/adaptor.go
+31
-25
relay/channel/task/doubao/constants.go
+2
-0
No files found.
relay/channel/task/doubao/adaptor.go
View file @
b7c0f754
...
...
@@ -13,7 +13,7 @@ import (
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/relay/channel"
taskcommon
"github.com/QuantumNous/new-api/relay/channel/task/taskcommon"
"github.com/QuantumNous/new-api/relay/channel/task/taskcommon"
relaycommon
"github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/service"
...
...
@@ -26,37 +26,37 @@ import (
// ============================
type
ContentItem
struct
{
Type
string
`json:"type"`
// "text", "image_url" or "video"
Text
string
`json:"text,omitempty"`
// for text type
ImageURL
*
ImageURL
`json:"image_url,omitempty"`
// for image_url type
Video
*
VideoReference
`json:"video,omitempty"`
// for video (sample) type
Role
string
`json:"role,omitempty"`
// reference_image / first_frame / last_frame
Type
string
`json:"type,omitempty"`
Text
string
`json:"text,omitempty"`
ImageURL
*
MediaURL
`json:"image_url,omitempty"`
VideoURL
*
MediaURL
`json:"video_url,omitempty"`
AudioURL
*
MediaURL
`json:"audio_url,omitempty"`
Role
string
`json:"role,omitempty"`
}
type
ImageURL
struct
{
URL
string
`json:"url"`
}
type
VideoReference
struct
{
URL
string
`json:"url"`
// Draft video URL
type
MediaURL
struct
{
URL
string
`json:"url,omitempty"`
}
type
requestPayload
struct
{
Model
string
`json:"model"`
Content
[]
ContentItem
`json:"content"`
Content
[]
ContentItem
`json:"content
,omitempty
"`
CallbackURL
string
`json:"callback_url,omitempty"`
ReturnLastFrame
*
dto
.
BoolValue
`json:"return_last_frame,omitempty"`
ServiceTier
string
`json:"service_tier,omitempty"`
ExecutionExpiresAfter
dto
.
IntValue
`json:"execution_expires_after,omitempty"`
ExecutionExpiresAfter
*
dto
.
IntValue
`json:"execution_expires_after,omitempty"`
GenerateAudio
*
dto
.
BoolValue
`json:"generate_audio,omitempty"`
Draft
*
dto
.
BoolValue
`json:"draft,omitempty"`
Resolution
string
`json:"resolution,omitempty"`
Ratio
string
`json:"ratio,omitempty"`
Duration
dto
.
IntValue
`json:"duration,omitempty"`
Frames
dto
.
IntValue
`json:"frames,omitempty"`
Seed
dto
.
IntValue
`json:"seed,omitempty"`
CameraFixed
*
dto
.
BoolValue
`json:"camera_fixed,omitempty"`
Watermark
*
dto
.
BoolValue
`json:"watermark,omitempty"`
Tools
[]
struct
{
Type
string
`json:"type,omitempty"`
}
`json:"tools,omitempty"`
Resolution
string
`json:"resolution,omitempty"`
Ratio
string
`json:"ratio,omitempty"`
Duration
*
dto
.
IntValue
`json:"duration,omitempty"`
Frames
*
dto
.
IntValue
`json:"frames,omitempty"`
Seed
*
dto
.
IntValue
`json:"seed,omitempty"`
CameraFixed
*
dto
.
BoolValue
`json:"camera_fixed,omitempty"`
Watermark
*
dto
.
BoolValue
`json:"watermark,omitempty"`
}
type
responsePayload
struct
{
...
...
@@ -76,9 +76,15 @@ type responseTask struct {
Ratio
string
`json:"ratio"`
FramesPerSecond
int
`json:"framespersecond"`
ServiceTier
string
`json:"service_tier"`
Usage
struct
{
Tools
[]
struct
{
Type
string
`json:"type"`
}
`json:"tools"`
Usage
struct
{
CompletionTokens
int
`json:"completion_tokens"`
TotalTokens
int
`json:"total_tokens"`
ToolUsage
struct
{
WebSearch
int
`json:"web_search"`
}
`json:"tool_usage"`
}
`json:"usage"`
CreatedAt
int64
`json:"created_at"`
UpdatedAt
int64
`json:"updated_at"`
...
...
@@ -108,12 +114,12 @@ func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycom
}
// BuildRequestURL constructs the upstream URL.
func
(
a
*
TaskAdaptor
)
BuildRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
func
(
a
*
TaskAdaptor
)
BuildRequestURL
(
_
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
return
fmt
.
Sprintf
(
"%s/api/v3/contents/generations/tasks"
,
a
.
baseURL
),
nil
}
// BuildRequestHeader sets required headers.
func
(
a
*
TaskAdaptor
)
BuildRequestHeader
(
c
*
gin
.
Context
,
req
*
http
.
Request
,
info
*
relaycommon
.
RelayInfo
)
error
{
func
(
a
*
TaskAdaptor
)
BuildRequestHeader
(
_
*
gin
.
Context
,
req
*
http
.
Request
,
_
*
relaycommon
.
RelayInfo
)
error
{
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
req
.
Header
.
Set
(
"Accept"
,
"application/json"
)
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
a
.
apiKey
)
...
...
@@ -231,7 +237,7 @@ func (a *TaskAdaptor) convertToRequestPayload(req *relaycommon.TaskSubmitReq) (*
for
_
,
imgURL
:=
range
req
.
Images
{
r
.
Content
=
append
(
r
.
Content
,
ContentItem
{
Type
:
"image_url"
,
ImageURL
:
&
Image
URL
{
ImageURL
:
&
Media
URL
{
URL
:
imgURL
,
},
})
...
...
relay/channel/task/doubao/constants.go
View file @
b7c0f754
...
...
@@ -5,6 +5,8 @@ var ModelList = []string{
"doubao-seedance-1-0-lite-t2v"
,
"doubao-seedance-1-0-lite-i2v"
,
"doubao-seedance-1-5-pro-251215"
,
"doubao-seedance-2-0-260128"
,
"doubao-seedance-2-0-fast-260128"
,
}
var
ChannelName
=
"doubao-video"
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