Repository navigation
fix(gateway): send ByteDance video ratio field - #2874
Conversation
ByteDance Ark's video generation API (Seedance) reads the aspect ratio from a top-level `ratio` field, not `aspect_ratio`. We were sending `aspect_ratio`, which Ark silently ignored and defaulted to 16:9, so portrait requests (e.g. size 720x1280 / 9:16) came back as landscape. Rename the upstream field to `ratio` and keep our response metadata's `aspect_ratio` sourced from the same computed value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe ByteDance video job flow now sends ChangesByteDance Ratio/Resolution Handling
Seedance Duration Support Expansion
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes ByteDance/Ark video generation aspect ratio handling by sending the upstream field ratio (instead of the ignored aspect_ratio) while keeping the gateway’s client-facing aspect_ratio metadata unchanged.
Changes:
- Update
createBytedanceVideoJobto compute the aspect ratio once and send it upstream asratio. - Preserve response metadata shape by continuing to expose
aspect_ratioderived from the same computed value. - Extend mocks/tests to capture and assert forwarded
ratio(andresolution) for both landscape and portrait Seedance requests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/gateway/src/videos/videos.ts | Sends ByteDance upstream ratio and keeps gateway aspect_ratio metadata stable. |
| apps/gateway/src/videos/videos.spec.ts | Adds assertions/tests verifying portrait/landscape sizes forward correct ratio/resolution to the ByteDance mock. |
| apps/gateway/src/test-utils/mock-openai-server.ts | Captures ratio (and resolution) in the ByteDance tasks mock for test assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Official ByteDance ModelArk docs allow the full [4,15] second range for the Seedance 2.0 series. Expand supportedVideoDurationsSeconds for seedance-2-0 and seedance-2-0-fast to 4-15, add the missing options to the playground duration picker, and update the video-generation docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Per official ByteDance ModelArk docs, Seedance 2.0 Fast supports 480p and 720p only; 1080p is exclusive to standard Seedance 2.0. Remove the 1080p sizes (1920x1080, 1080x1920) from the seedance-2-0-fast mapping so we no longer advertise unsupported resolutions, and update the video docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
Users reported that Seedance video jobs requesting a 9:16 (portrait) output were coming back as 16:9 (landscape) — the aspect ratio parameter was being ignored (e.g. task
xpaVAmcv5CHAqtZFCLIC).Root cause
ByteDance's Ark video generation API (
/contents/generations/tasks, used by Seedance 2.0 / 2.0 Fast / 1.5 Pro) reads the aspect ratio from a top-levelratiofield. We were sending it asaspect_ratio, which Ark silently ignores, defaulting the output to 16:9. So portrait sizes (720x1280,1080x1920) never took effect.Confirmed against the BytePlus ModelArk Seedance 2.0 API reference and multiple integration guides: the field is
ratio, alongside the already-correct top-levelresolutionanddurationfields.Fix
aspect_ratio->ratioincreateBytedanceVideoJob.aspect_ratiosourced from the same computed value (getBytedanceVideoAspectRatio), so no client-facing shape changes.Tests
1080x1920) forwardsratio: "9:16"andresolution: "1080p"to the ByteDance mock.ratio: "16:9"for landscape.ratio/resolution.Notes / out of scope
This PR only fixes the aspect-ratio bug that was explicitly requested. The other issues raised in the thread (15s duration support for Seedance 2.0 Fast, and the intermittent 401 on video downloads) are separate and not addressed here.
🤖 Generated with Claude Code
Summary by CodeRabbit