Skip to content

feat: doubao-seedance-2-0-260128支持按分辨率区分计费 - #5300

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/98678de84b106e8a0a917df644bc97f86bbb3475
Jun 30, 2026
Merged

feat: doubao-seedance-2-0-260128支持按分辨率区分计费#5300
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/98678de84b106e8a0a917df644bc97f86bbb3475

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jun 4, 2026

Copy link
Copy Markdown
Member

⚠️ 提交说明 / PR Notice

修复: #5266
image
sd2.0, 之前只根据是否包含视频url区分计费
新增了1080p分辨率后, 又增加了根据是否1080p区分计费

📝 变更描述 / Description

增加是否1080p计费配置, 与是否包含视频url配置成价格map
等后续将视频也支持表达式计费后可不再通过价格map写死 @Calcium-Ion

📸 运行证明 / Proof of Work

image 51/46=1.1087 比率正确

Summary by CodeRabbit

  • Chores
    • Updated billing estimation logic for video input pricing. The system now factors in output resolution when calculating video input cost adjustments, providing more granular pricing accuracy based on both resolution and video presence in requests.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Doubao billing estimator is updated to compute video-input discounts based on output resolution (1080p vs. non-1080p) and video presence. The pricing table replaces a fixed ratio map, and EstimateBilling now extracts resolution from metadata to apply resolution-aware discount calculation.

Changes

Doubao Video Input Pricing by Resolution

Layer / File(s) Summary
Resolution-aware video pricing table
relay/channel/task/doubao/constants.go
The pricing table is introduced with entries keyed by (resolution, hasVideo). The GetVideoInputRatio function signature changes from (modelName string) to (modelName, resolution string, hasVideo bool) and computes a multiplier relative to the configured base (no-video, non-1080p) price for each model. Missing base returns (0, false); missing specific entries default to (1.0, true). The strings import is added for case-insensitive resolution detection.
EstimateBilling resolution extraction
relay/channel/task/doubao/adaptor.go
TaskAdaptor.EstimateBilling extracts resolution from metadata and calls GetVideoInputRatio(info.OriginModelName, resolution, hasVideo) with all three parameters. The function returns {"video_input": ratio} only when a valid ratio exists and is not 1.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • QuantumNous/new-api#1951: Updates to the Doubao adaptor and constants build on the Doubao Video support introduced in #1951.

Suggested reviewers

  • seefs001
  • Calcium-Ion

Poem

🐰 A table of prices, now resolution-wise,
Where 1080p and video are counted with eyes,
The estimator hops through metadata springs,
Finding the resolution that pricing now brings,
Multipliers dance where the base prices lay.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately describes the main change: adding resolution-based billing differentiation (1080p vs non-1080p) for the doubao-seedance-2-0 model, which aligns with the code changes that refactored billing ratio calculation to accept and use resolution parameter.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

🧹 Nitpick comments (1)
relay/channel/task/doubao/constants.go (1)

40-45: 💤 Low value

Document/validate the base-price ↔ ModelRatio coupling.

The multiplier is price/base where base is the hard-coded 480p/720p no-video price (46.0 / 37.0). Billing is only correct if the admin-configured ModelRatio equals that base. The comment notes this, but it's a silent assumption: if ModelRatio is set to any other value the resolution/video multipliers will be proportionally wrong. Consider surfacing this expectation in operator docs.

🤖 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/constants.go` around lines 40 - 45,
GetVideoInputRatio assumes admin-configured ModelRatio equals the hard-coded
base price (videoPriceTable lookup using videoPriceKey{}), which silently breaks
billing if ModelRatio differs; update GetVideoInputRatio (and related
initialization) to validate that ModelRatio matches the expected base
(videoPriceTable[modelName][videoPriceKey{}]) and either compute multipliers
relative to the configured ModelRatio or emit a clear runtime warning/error when
they diverge; reference videoPriceTable, videoPriceKey{}, base and ModelRatio so
the code locates the check and handle the mismatch by logging an explicit error
or adjusting calculations to use the configured ModelRatio as the denominator.
🤖 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.

Nitpick comments:
In `@relay/channel/task/doubao/constants.go`:
- Around line 40-45: GetVideoInputRatio assumes admin-configured ModelRatio
equals the hard-coded base price (videoPriceTable lookup using videoPriceKey{}),
which silently breaks billing if ModelRatio differs; update GetVideoInputRatio
(and related initialization) to validate that ModelRatio matches the expected
base (videoPriceTable[modelName][videoPriceKey{}]) and either compute
multipliers relative to the configured ModelRatio or emit a clear runtime
warning/error when they diverge; reference videoPriceTable, videoPriceKey{},
base and ModelRatio so the code locates the check and handle the mismatch by
logging an explicit error or adjusting calculations to use the configured
ModelRatio as the denominator.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80877c64-7592-44a0-a741-af98150f6ef9

📥 Commits

Reviewing files that changed from the base of the PR and between 00d23ab and 09fe119.

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

@feitianbubu feitianbubu changed the title feat: doubao-seedance-2-0-260128支持按1080p额外计费 feat: doubao-seedance-2-0-260128支持按分辨率区分计费 Jun 4, 2026
@huhu-tiger

Copy link
Copy Markdown

前端模型广场 显示还是没有区分计费

@zhuiyue132

Copy link
Copy Markdown

需要这个feat,尽快合并

@Calcium-Ion
Calcium-Ion merged commit c8491b4 into QuantumNous:main Jun 30, 2026
2 checks 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 <i@caion.me>

* 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 <i@caion.me>
Co-authored-by: feitianbubu <feitianbubu@qq.com>
Co-authored-by: t0ng7u <dev@aiass.cc>
Co-authored-by: olwater <52482488+olwater@users.noreply.github.com>
Co-authored-by: Scott <sc908181134@gmail.com>
Co-authored-by: QuentinHsu <xuquentinyang@gmail.com>
Co-authored-by: henrydontbbai <268972047+henrydontbbai@users.noreply.github.com>
0401lucky pushed a commit to 0401lucky/new-api that referenced this pull request Jul 7, 2026
fran0220 pushed a commit to fran0220/you-box that referenced this pull request Jul 9, 2026
ySion pushed a commit to FrostFoxAtelier/new-api that referenced this pull request Jul 17, 2026
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.

4 participants