Skip to content

fix(gateway): send ByteDance video ratio field - #2874

Merged
steebchen merged 3 commits into
mainfrom
fix/seedance-aspect-ratio
Jul 1, 2026
Merged

steebchen merged 3 commits into
mainfrom
fix/seedance-aspect-ratio

Conversation

@steebchen

@steebchen steebchen commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

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-level ratio field. We were sending it as aspect_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-level resolution and duration fields.

Fix

  • Rename the upstream request field aspect_ratio -> ratio in createBytedanceVideoJob.
  • Keep the gateway's own response metadata aspect_ratio sourced from the same computed value (getBytedanceVideoAspectRatio), so no client-facing shape changes.

Tests

  • Added a test asserting a portrait size (1080x1920) forwards ratio: "9:16" and resolution: "1080p" to the ByteDance mock.
  • Extended the existing Seedance 2.0 test to assert ratio: "16:9" for landscape.
  • Mock ByteDance endpoint now captures 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

  • Bug Fixes
    • Corrected Bytedance Seedance job requests so the correct ratio metadata is sent and saved.
    • Portrait-size generations now yield the expected vertical ratio, resolution, and duration.
    • Frame-input flows now preserve ratio metadata in results.
  • New Supported Options
    • Expanded Seedance-supported video durations to 4–15 seconds.
    • Seedance 2.0 Fast size support is now restricted to two portrait/landscape variants.
  • Documentation
    • Updated the Video Generation model catalog, size/duration tables, and pricing details.
  • Tests
    • Strengthened test coverage for Seedance ratio, resolution, and duration expectations.

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>
Copilot AI review requested due to automatic review settings July 1, 2026 11:46
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 069e0b07-fab3-4c35-8e8f-0acb2f6e0d53

📥 Commits

Reviewing files that changed from the base of the PR and between 7e18065 and be0c467.

📒 Files selected for processing (4)
  • apps/docs/content/features/video-generation.mdx
  • apps/gateway/src/videos/videos.spec.ts
  • apps/playground/src/lib/video-gen.ts
  • packages/models/src/models/bytedance.ts

Walkthrough

The ByteDance video job flow now sends ratio instead of aspect_ratio, stores ratio and resolution in the mock job state, and adds tests for portrait and frame-input cases. Seedance duration support was expanded to 4–15 seconds across playground types, model capability data, and docs.

Changes

ByteDance Ratio/Resolution Handling

Layer / File(s) Summary
Upstream request and response ratio field
apps/gateway/src/videos/videos.ts
createBytedanceVideoJob computes videoRatio, sends it as ratio in the upstream request, and uses the same value for response metadata.
Mock server ratio/resolution persistence
apps/gateway/src/test-utils/mock-openai-server.ts
MockVideoJobState gains ratio, and mocked task creation stores ratio and resolution from the request body.
Tests validating ratio and resolution
apps/gateway/src/videos/videos.spec.ts
The frame-input test asserts ratio is 16:9, and a new portrait-size test checks ratio 9:16, resolution 1080p, and duration 15.

Seedance Duration Support Expansion

Layer / File(s) Summary
Duration contract and model registry
apps/playground/src/lib/video-gen.ts, packages/models/src/models/bytedance.ts
VideoDuration and VIDEO_DURATIONS now cover 4 through 15, and Seedance 2.0 / 2.0 Fast capability data lists the same supported duration range.
Video generation docs update
apps/docs/content/features/video-generation.mdx
The video-generation docs update Seedance model listings, split the duration table rows, and remove the old Seedance 2.0 Fast 1080p pricing row.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • theopenco/llmgateway#2270: Shares the same ByteDance job-construction path and upstream payload handling in apps/gateway/src/videos/videos.ts.
  • theopenco/llmgateway#2538: Also modifies createBytedanceVideoJob and the ByteDance upstream content payload structure.
  • theopenco/llmgateway#2768: Touches apps/playground/src/lib/video-gen.ts and the same duration set used by VideoDuration and VIDEO_DURATIONS.

Suggested reviewers: smakosh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: sending ByteDance video ratio via the upstream request field.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/seedance-aspect-ratio

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 createBytedanceVideoJob to compute the aspect ratio once and send it upstream as ratio.
  • Preserve response metadata shape by continuing to expose aspect_ratio derived from the same computed value.
  • Extend mocks/tests to capture and assert forwarded ratio (and resolution) 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.

steebchen and others added 2 commits July 1, 2026 13:06
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>
@steebchen
steebchen merged commit 97141a4 into main Jul 1, 2026
10 of 11 checks passed
@steebchen
steebchen deleted the fix/seedance-aspect-ratio branch July 1, 2026 12:11
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