Skip to content

feat: support doubao seedance 2.0 safety_identifier/priority and 4k billing - #5824

Merged
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
feitianbubu:feat/doubao-seedance2-fields-4k
Jun 30, 2026
Merged

Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
feitianbubu:feat/doubao-seedance2-fields-4k

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

📝 变更描述 / Description

官方文档: https://www.volcengine.com/docs/82379/1520757

为 Doubao Seedance 2.0 系列视频模型补齐两处与官方接口对齐的改动:

  1. 请求参数补齐:requestPayload 新增 safety_identifier(终端用户唯一标识)与 priority(队列优先级,仅 Seedance 2.0 支持)两个字段,经 metadata 透传至上游。priority 采用指针类型,以区分「未传」与「显式传 0」,避免零值被 omitempty 丢弃。
image
  1. 4K 分辨率计费:
image

✅ 提交前检查项 / Checklist

  • 人工确认: 描述由人工整理撰写。
  • 非重复提交: 已确认无重复 PR。
  • 变更理解: 已理解改动原理与影响范围。
  • 范围聚焦: 仅改动 doubao 视频适配器,无无关改动。
  • 本地验证: go build ./relay/channel/task/doubao/ 通过。
  • 安全合规: 无敏感凭据,符合代码规范。

📸 运行证明 / Proof of Work

修复前,按720计费, 9元/秒
image
修复后: 按4k正确计费 5元/秒
image

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds 4K resolution support to Doubao video pricing by extending the videoPriceKey struct with an is4k field and updating videoPriceTable entries. GetVideoInputRatio now normalizes resolution strings before lookup. The tools item payload struct gains two new optional fields: SafetyIdentifier and Priority.

Changes

Doubao video pricing and tool payload

Layer / File(s) Summary
4K video pricing key and resolution normalization
relay/channel/task/doubao/constants.go
videoPriceKey gains is4k bool, videoPriceTable adds 4K-keyed price entries for model 260128, and GetVideoInputRatio normalizes resolution via strings.ToLower/strings.TrimSpace before setting is1080p/is4k booleans for the map lookup.
Tool payload new optional fields
relay/channel/task/doubao/adaptor.go
The anonymous tools item struct adds SafetyIdentifier string (json: safety_identifier) and Priority *dto.IntValue (json: priority) as omitempty fields alongside existing optional fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • QuantumNous/new-api#5300: Introduced the original resolution-based GetVideoInputRatio logic that this PR extends with 4K support and input normalization.

Suggested reviewers

  • Calcium-Ion

🐇 A new dimension of 4K delight,
The pricing key grows one field to the right.
SafetyIdentifier joins the tools array,
Priority hops in without delay—
The rabbit approves, normalizing with glee! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main changes: new SafetyIdentifier/Priority request fields and 4K billing support for Doubao Seedance 2.0.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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.

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@relay/channel/task/doubao/adaptor.go`:
- Around line 55-63: The tool metadata fields are currently defined after the
anonymous Tools struct is closed, so they serialize at the top level of
requestPayload instead of inside each tool item. Move SafetyIdentifier,
Priority, Resolution, Ratio, Duration, Frames, Seed, CameraFixed, and Watermark
back into the Tools item payload definition in adaptor.go, and verify the
request shape produced by the relevant payload struct matches the upstream tool
schema.
- Line 55: The optional safety_identifier field in the Doubao adapter request
struct is using a plain string, which loses the distinction between omitted and
explicitly empty values when re-marshaled. Update the request type in adaptor.go
so SafetyIdentifier uses pointer semantics like Priority, and ensure the
upstream JSON payload preserves absence vs empty value through the existing
marshal path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 20e0a36b-757b-4f41-8878-b63fa7903f32

📥 Commits

Reviewing files that changed from the base of the PR and between c8491b4 and 5e831be.

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

Seed *dto.IntValue `json:"seed,omitempty"`
CameraFixed *dto.BoolValue `json:"camera_fixed,omitempty"`
Watermark *dto.BoolValue `json:"watermark,omitempty"`
SafetyIdentifier string `json:"safety_identifier,omitempty"`

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use a pointer for optional safety_identifier.

With omitempty, a plain string collapses “absent” and explicit "" into the same outbound payload. This adapter is re-marshaling client JSON upstream, so safety_identifier needs pointer semantics just like priority.

Proposed fix
-	SafetyIdentifier string         `json:"safety_identifier,omitempty"`
+	SafetyIdentifier *string        `json:"safety_identifier,omitempty"`

As per coding guidelines, “For request structs parsed from client JSON and re-marshaled to upstream providers, use pointer types for optional scalar fields with omitempty tags.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SafetyIdentifier string `json:"safety_identifier,omitempty"`
SafetyIdentifier *string `json:"safety_identifier,omitempty"`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/adaptor.go` at line 55, The optional
safety_identifier field in the Doubao adapter request struct is using a plain
string, which loses the distinction between omitted and explicitly empty values
when re-marshaled. Update the request type in adaptor.go so SafetyIdentifier
uses pointer semantics like Priority, and ensure the upstream JSON payload
preserves absence vs empty value through the existing marshal path.

Source: Coding guidelines

Comment on lines +55 to +63
SafetyIdentifier string `json:"safety_identifier,omitempty"`
Priority *dto.IntValue `json:"priority,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"`

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Move these fields back into the tools item payload.

The anonymous Tools struct is already closed on Line 54, so safety_identifier, priority, and the related video options serialize at the top level of requestPayload instead of under each tool entry. That breaks the upstream schema the PR summary describes for tool metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/adaptor.go` around lines 55 - 63, The tool metadata
fields are currently defined after the anonymous Tools struct is closed, so they
serialize at the top level of requestPayload instead of inside each tool item.
Move SafetyIdentifier, Priority, Resolution, Ratio, Duration, Frames, Seed,
CameraFixed, and Watermark back into the Tools item payload definition in
adaptor.go, and verify the request shape produced by the relevant payload struct
matches the upstream tool schema.

@Calcium-Ion
Calcium-Ion merged commit e514db2 into QuantumNous:main Jun 30, 2026
1 check passed
henrydontbbai added a commit to henrydontbbai/henry-newapi that referenced this pull request Jul 2, 2026
* feat: improve advanced custom route editor

* Bump Electron lockfile dependencies

* feat: bill doubao seedance-2.0 by output resolution and video input (QuantumNous#5300)

* feat: support doubao seedance 2.0 safety_identifier/priority and 4k billing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

* chore: run `bun format` to automatically format the frontend code

* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题 (QuantumNous#5795)

* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>

* feat: support Wan2.7 i2v media mapping (QuantumNous#4984)

* feat: support Wan2.7 i2v media mapping

* fix: normalize wan2.7 i2v image inputs

* perf(web): optimize web Rsbuild and Tailwind build pipeline (QuantumNous#5786)

* fix(dev): run only default frontend in dev-web

- simplify make dev-web to install default dependencies and start web/default only.
- keep dev-web-classic as the standalone classic entry and scope its install to classic.

* chore(build): align make targets with web naming

- rename frontend make targets and variables to use the web terminology consistently.
- keep default and classic dev port overrides available under the updated names.

* fix(web): inject app styles into isolated HTML (QuantumNous#5860)

- clone loaded application style nodes into the Shadow DOM for custom HTML rendering.
- keep HTML rendering isolated while restoring layout and typography that depend on app CSS.

* fix: keep page state when switching tabs within the same route (QuantumNous#5796)

AnimatedOutlet keyed its motion container by the full pathname, so
navigating between params of the same route (e.g. the dashboard tabs
under /dashboard/$section) changed the key and remounted the route
component, discarding its in-memory state. The most visible symptom:
the dashboard time range resets to the default every time you switch
sub-tabs (Model Analytics / Flow / User Analytics).

Key the transition by the matched route id instead, so param-only
navigation re-renders in place while real page-to-page navigation
still plays the enter animation. This also preserves state across the
other $section tab pages (usage logs, models, system settings).

* 支持服务优雅关闭,避免重启回复中断和面板缓存数据丢失 (QuantumNous#4258)

* feat: add graceful shutdown with configurable timeout

* fix: flush quota dashboard cache on graceful shutdown

Persist the in-memory CacheQuotaData aggregation to the quota_data table
before process exit, so a restart no longer drops up to one DataExportInterval
window of dashboard data (issue QuantumNous#5679).

* docs: update AGENTS.md

* Make quota logging synchronous and delay startup log

---------

Co-authored-by: CaIon <[email protected]>
Co-authored-by: feitianbubu <[email protected]>
Co-authored-by: t0ng7u <[email protected]>
Co-authored-by: olwater <[email protected]>
Co-authored-by: Scott <[email protected]>
Co-authored-by: QuentinHsu <[email protected]>
Co-authored-by: henrydontbbai <[email protected]>
liulixin-lex pushed a commit to liulixin-lex/xy-api that referenced this pull request Jul 7, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
0401lucky pushed a commit to 0401lucky/new-api that referenced this pull request Jul 7, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

(cherry picked from commit e514db2)
fran0220 pushed a commit to fran0220/you-box that referenced this pull request Jul 9, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

(cherry picked from commit e514db2)
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
ySion pushed a commit to FrostFoxAtelier/new-api that referenced this pull request Jul 17, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

(cherry picked from commit e514db2)
noah-wung pushed a commit to noah-wung/new-api that referenced this pull request Jul 17, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
dofastted pushed a commit to dofastted/new-api that referenced this pull request Sep 16, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

(cherry picked from commit e514db2)
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…illing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video
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.

2 participants