Skip to content

新增seedance2.0视频接口支持 - #4042

Merged
Calcium-Ion merged 5 commits into
QuantumNous:mainfrom
feitianbubu:pr/fe9713dcbf8795e127fbea2fcb1f3011da86ad54
Apr 2, 2026
Merged

新增seedance2.0视频接口支持#4042
Calcium-Ion merged 5 commits into
QuantumNous:mainfrom
feitianbubu:pr/fe9713dcbf8795e127fbea2fcb1f3011da86ad54

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Apr 2, 2026

Copy link
Copy Markdown
Member

官方文档: https://www.volcengine.com/docs/82379/1520757?lang=zh
模型id: doubao-seedance-2-0-260128, doubao-seedance-2-0-fast-260128

请求示例: openai /v1/videos兼容格式

curl http://localhost:30001/v1/videos \
  --request POST \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=test' \
  --form 'model=doubao-seedance-2-0-260128' \
  --form 'metadata={
"content": [
{
"type": "video_url",
"video_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_video/r2v_extend_video2.mp4"
},
"role": "reference_video"
}
]
}'
image image

Summary by CodeRabbit

  • New Features

    • Support for two new high-performance video generation models
    • Added Tools and web search integration capabilities
    • Enhanced media content handling with improved support for video and audio formats
  • Bug Fixes

    • Improved error reporting with detailed error messages from services instead of generic failure notifications
    • Better error propagation for video generation requests

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The Doubao video task adaptor undergoes schema and logic updates: request payloads are restructured with new optional fields and Tools support; content types unified using MediaURL; request construction now manages Duration from metadata and ensures single text prompt; response mapping extracts error details from API responses; error propagation in OpenAI conversion refactored. Two new model identifiers added to constants.

Changes

Cohort / File(s) Summary
Request and response logic refactoring
relay/channel/task/doubao/adaptor.go
Updated request payload schema with JSON field tags (content,omitempty), changed ExecutionExpiresAfter to pointer type, added Tools list, and adjusted optional fields to pointers. Replaced ImageURL/VideoReference with unified MediaURL. Reworked request construction to set Duration from metadata, remove existing text items, and append single text prompt. Modified response mapping to extract error messages from API response instead of constants. Updated method signatures to mark unused parameters as _.
Model identifier expansion
relay/channel/task/doubao/constants.go
Added two new model identifiers (doubao-seedance-2-0-260128, doubao-seedance-2-0-fast-260128) to ModelList.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • seefs001
  • Calcium-Ion

Poem

🐰 A Doubao hop with schemas new,
MediaURL hops replace the few,
Errors whisper from responses true,
Text prompts sing in singles too,
Two seedance models join the brew! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title refers to adding Seedance 2.0 video API support, which directly aligns with the main changes across the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
relay/channel/task/doubao/adaptor.go (1)

288-295: ⚠️ Potential issue | 🟠 Major

Handle expired status as terminal failure in both locations.

The Doubao/Seedance API returns expired for timed-out tasks after execution_expires_after is reached. Currently, this status falls through to the default case (line 288-295) and is treated as in-progress, causing expired tasks to keep polling indefinitely. The OpenAI conversion (line 317-321) also only checks for failed, missing the error case for expired. Both locations must treat expired as a terminal failure.

🛠️ Proposed fix
-	case "failed":
+	case "failed", "expired":
 		taskResult.Status = model.TaskStatusFailure
 		taskResult.Progress = "100%"
-		taskResult.Reason = resTask.Error.Message
+		if resTask.Error.Message != "" {
+			taskResult.Reason = resTask.Error.Message
+		} else {
+			taskResult.Reason = resTask.Status
+		}
@@
-	if dResp.Status == "failed" {
+	if dResp.Status == "failed" || dResp.Status == "expired" {
 		openAIVideo.Error = &dto.OpenAIVideoError{
 			Message: dResp.Error.Message,
 			Code:    dResp.Error.Code,
 		}
 	}

Also applies to: 317-321

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@relay/channel/task/doubao/adaptor.go` around lines 288 - 295, The "expired"
status must be treated as a terminal failure like "failed": in the status switch
(where taskResult.Status, taskResult.Progress and taskResult.Reason are set
based on resTask.Status) add "expired" to the failure branch so
taskResult.Status = model.TaskStatusFailure, taskResult.Progress = "100%" and
taskResult.Reason = resTask.Error.Message; likewise, in the OpenAI conversion
block (the branch that currently checks only for "failed" around the lines
handling conversion) include "expired" alongside "failed" so it is mapped to the
same terminal failure handling instead of falling through to
TaskStatusInProgress.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@relay/channel/task/doubao/adaptor.go`:
- Around line 288-295: The "expired" status must be treated as a terminal
failure like "failed": in the status switch (where taskResult.Status,
taskResult.Progress and taskResult.Reason are set based on resTask.Status) add
"expired" to the failure branch so taskResult.Status = model.TaskStatusFailure,
taskResult.Progress = "100%" and taskResult.Reason = resTask.Error.Message;
likewise, in the OpenAI conversion block (the branch that currently checks only
for "failed" around the lines handling conversion) include "expired" alongside
"failed" so it is mapped to the same terminal failure handling instead of
falling through to TaskStatusInProgress.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b4b2cb4a-9131-450f-8ba3-5dd37910792c

📥 Commits

Reviewing files that changed from the base of the PR and between a706f00 and dafc761.

📒 Files selected for processing (2)
  • relay/channel/task/doubao/adaptor.go
  • relay/channel/task/doubao/constants.go

@Calcium-Ion
Calcium-Ion merged commit 0193018 into QuantumNous:main Apr 2, 2026
1 check passed
VeryGoodUser1 pushed a commit to xmz-ai/new-api that referenced this pull request Apr 3, 2026
…5e127fbea2fcb1f3011da86ad54

新增seedance2.0视频接口支持
@MEIS-DaCaiTou

Copy link
Copy Markdown

20260408-111703
20260408-111905

我使用以下参数进行调用生成视频返回的视频时长还是5s,不是参数传入的11s,辛苦看下是什么原因导致的,谢谢了。
curl http://localhost:30001/v1/videos
--request POST
--form 'prompt=第一人称视角果茶宣传广告,seedance牌「苹苹安安」苹果果茶限定款;首帧为图片1,你的手摘下一颗带晨露的阿克苏红苹果,轻脆的苹果碰撞声;2-4 秒:快速切镜,你的手将苹果块投入雪克杯,加入冰块与茶底,用力摇晃,冰块碰撞声与摇晃声卡点轻快鼓点,背景音:「鲜切现摇」;4-6 秒:第一人称成品特写,分层果茶倒入透明杯,你的手轻挤奶盖在顶部铺展,在杯身贴上粉红包标,镜头拉近看奶盖与果茶的分层纹理;6-8 秒:第一人称手持举杯,你将图片2中的果茶举到镜头前(模拟递到观众面前的视角),杯身标签清晰可见,背景音「来一口鲜爽」,尾帧定格为图片2。背景声音统一为女生音色。全程使用视频1的第一视角构图,全程使用音频1作为背景音乐。'
--form 'model=doubao-seedance-2-0-fast-260128'
--form 'generate_audio=true'
--form 'ratio=16:9'
--form 'duration=11'
--form 'watermark=false'
--form 'metadata={
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic1.jpg"
},
"role": "reference_image"
},
{
"type": "image_url",
"image_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic2.jpg"
},
"role": "reference_image"
},
{
"type": "video_url",
"video_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_video/r2v_tea_video1.mp4"
},
"role": "reference_video"
},
{
"type": "audio_url",
"audio_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_audio/r2v_tea_audio1.mp3"
},
"role": "reference_audio"
}
]
}'

@feitianbubu

Copy link
Copy Markdown
Member Author

支持秒的在这个pr #4068
使用最新版本再试一下?

@lihengyang

Copy link
Copy Markdown

您这里更新了,new API的video generation API仿佛还没有更新。请作者尽快更新一下?

@ztj7728

ztj7728 commented Apr 25, 2026

Copy link
Copy Markdown

v0.12.11 仍然无法正确透传duration。

curl --location 'https:///v1/video/generations'
--header 'Authorization: Bearer sk-'
--form 'model="doubao-seedance-2-0-fast-260128"'
--form 'prompt="****"'
--form 'duration="4"'

或者

curl --location 'https:///v1/video/generations'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer sk-'
--data '{
"model": "doubao-seedance-2-0-fast-260128",
"prompt": "***",
"duration": 4
}'

最终生成的视频都是5秒的。

@feitianbubu

Copy link
Copy Markdown
Member Author

走 openai /v1/videos兼容格式
duration 改成 seconds
如果一定要用deedance的 duration参数 要放到metadata里调用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants