Skip to content

feat: support doubao image video model#577

Merged
zijiren233 merged 2 commits into
labring:mainfrom
zijiren233:doubao-image-video
May 21, 2026
Merged

feat: support doubao image video model#577
zijiren233 merged 2 commits into
labring:mainfrom
zijiren233:doubao-image-video

Conversation

@zijiren233
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Doubao (Volc/Ark) adaptor support for image generation and video generation/v1 videos APIs, including async usage fetching so the proxy can meter video jobs after completion.

Changes:

  • Add Doubao image generations request normalization and response/stream conversion with usage accounting.
  • Add Doubao video job submit/status/content handlers, including multipart support and store caching for job/generation IDs.
  • Implement Doubao async-usage fetcher for video jobs and extend adaptor routing/support + tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/relay/adaptor/doubao/video.go Implements Doubao video request conversion, task submit/status/content handlers, and store caching for jobs/generations.
core/relay/adaptor/doubao/video_helpers.go Adds parsing/normalization helpers for Doubao video request fields (ints/bools/nested url/id, ratio derivation).
core/relay/adaptor/doubao/image.go Implements Doubao image generations conversion + response/stream handlers and usage mapping.
core/relay/adaptor/doubao/async_usage.go Adds async usage fetcher for Doubao video tasks (poll task status and map usage/context).
core/relay/adaptor/doubao/main.go Wires new Doubao image/video modes into URL routing, request conversion, and response handling.
core/relay/adaptor/doubao/main_test.go Extends tests to cover new modes/URLs, image normalization/usage/streaming, video conversion/store saving, and async usage fetching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

job.Width, job.Height = doubaoVideoDimensions(response.Resolution, response.Ratio)

if status == relaymodel.VideoGenerationJobStatusSucceeded ||
status == relaymodel.VideoGenerationJobStatus("failed") {
Comment on lines +159 to +166
Resolution: firstNonEmptyString(
stringFromAny(raw["resolution"]),
stringFromAny(raw["size"]),
),
Ratio: firstNonEmptyString(
stringFromAny(raw["ratio"]),
ratioFromSize(stringFromAny(raw["size"])),
),
Comment on lines +195 to +210
func parseDoubaoMultipartVideoRequest(req *http.Request) (doubaoVideoRequest, error) {
if err := common.ParseMultipartFormWithLimit(req); err != nil {
return doubaoVideoRequest{}, fmt.Errorf("parse multipart form: %w", err)
}

request := doubaoVideoRequest{
CallbackURL: req.PostFormValue("callback_url"),
ServiceTier: req.PostFormValue("service_tier"),
SafetyIdentifier: req.PostFormValue("safety_identifier"),
Resolution: firstNonEmptyString(
req.PostFormValue("resolution"),
req.PostFormValue("size"),
),
Ratio: firstNonEmptyString(
req.PostFormValue("ratio"),
ratioFromSize(req.PostFormValue("size")),
@zijiren233 zijiren233 merged commit 6486d81 into labring:main May 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants