Skip to content

feat(video): add dashscope_video provider for Wan 3.0 - #699

Open
hoobnn wants to merge 3 commits into
OpenMontageInc:mainfrom
hoobnn:feat/dashscope-wan3-video
Open

hoobnn wants to merge 3 commits into
OpenMontageInc:mainfrom
hoobnn:feat/dashscope-wan3-video

Conversation

@hoobnn

@hoobnn hoobnn commented Oct 4, 2026 •

Copy link
Copy Markdown

Summary

Adds dashscope_video, a DashScope (Alibaba Cloud Bailian / 阿里云百炼) video tool backed by Wan 3.0: wan3.0-video by default, or the faster wan3.0-video-prime. Users who already have DASHSCOPE_API_KEY for dashscope_image / dashscope_tts / dashscope_asr get video generation from the same key. The tool supports text-to-video, image-to-video, first/last-frame, and reference-to-video (images, videos, and audio), with native audio and clips up to 30s.

Wan 3.0 currently ranks near the top of the public text-to-video leaderboards (Artificial Analysis #1, LMArena #6). It is also one of the cheaper top-tier options per second, and Chinese prompts and Mandarin dialogue are first-class. The only existing Wan path is the local-GPU wan_video (Wan 2.x).

Design notes

  • Async flow: submit to the DashScope-native video-synthesis endpoint with X-DashScope-Async: enable, poll /api/v1/tasks/{task_id}, then download video_url immediately because it expires after 24h. Timeouts and failures return task_id so a job can be recovered.
  • Defaults to 720P. The API defaults to 1080P, which bills 2x per second. A caller who omits resolution should not silently pay double.
  • Local media without fal.ai. Local images, videos, and audio are inlined as base64 data URIs (data:{mime};base64,..., a format the API accepts). image_url is intentionally not declared in input_schema: video_selector uploads reference_image_path to fal.ai for any provider that declares it, and that would make this tool require FAL_KEY. A selector routing test covers this.
  • Region: DASHSCOPE_REGION=intl (also international / singapore) selects dashscope-intl.aliyuncs.com, and DASHSCOPE_BASE_URL overrides the endpoint. These are the same variable names and values proposed for dashscope_image in Fix DashScope intl endpoint and Explainer prop forwarding #584, so the two PRs compose cleanly. This PR does not touch dashscope_image.py.
  • Cost: per-model, per-resolution, per-second rates at the Singapore list price, which the official model pages show as the most expensive region for both models. That makes the estimate an upper bound everywhere: wan3.0-video ~$0.052 / $0.104 / $0.208, wan3.0-video-prime $0.068 / $0.14 / $0.28 (480P / 720P / 1080P). duration=-1 (model-chosen length) is budgeted at the 30s maximum, then reconciled against usage.output_video_duration after the task finishes.
  • Models: wan3.0-video (default) and wan3.0-video-prime share one request shape; only the price differs, so model is a plain enum.

Changes

  • tools/video/dashscope_video.py: the new tool, discovered automatically by the registry and video_selector.
  • tests/contracts/test_dashscope_video.py: payload construction for every operation, input validation, region routing, cost, and the execute path (success with polling and download, submit error, failed task, timeout, missing key). It also covers selector routing for image_to_video with a local reference_image_path.
  • tests/contracts/test_dashscope_tools.py: adds the tool to the shared DashScope contract suite and the discovery test.
  • .agents/skills/dashscope/SKILL.md, docs/PROVIDERS.md, .env.example: video API notes, parameters, pricing, troubleshooting, and the optional region variables.

Verification

  • pytest tests: 1930 passed, 12 skipped, 3 xfailed.
  • Real end-to-end run against the mainland endpoint: text_to_video, duration=2, resolution=480P. The task (6178e23b-c6b7-4272-8d50-d50670e6cf9b) succeeded in 82s and produced an 854x480, 30fps H.264 clip with an AAC audio track (2.02s). usage.output_video_duration=2 reconciled the reported cost to $0.10.
  • The same run with wan3.0-video-prime (task d041938e-e448-4480-9702-c75de41f29aa) succeeded in 89s with identical output specs. The reported cost was $0.14. A single sample showed no speedup, which is likely queue noise.
  • Probes with deliberately invalid parameters confirmed which model IDs exist on the mainland endpoint. wan3.0-video and wan3.0-video-prime exist; wan3.0-t2v and wan3.0-i2v return Model not exist. Note that the /compatible-mode/v1/models listing does not show video models at all.

API reference: https://help.aliyun.com/zh/model-studio/wan3-video-generation-api-reference

Assisted by Claude Code

Adds a DashScope (Alibaba Cloud Bailian) video tool backed by
wan3.0-video, so an existing DASHSCOPE_API_KEY unlocks text, image,
first/last-frame, and reference-to-video generation with native audio.

- Async submit/poll/download against the DashScope-native
  video-synthesis endpoint; timeouts and failures keep task_id.
- Defaults to 720P instead of the API's 1080P default, which bills
  2x per second.
- Local images/videos/audio are inlined as base64 data URIs, so the
  selector's fal.ai upload path (and FAL_KEY) is not required.
- DASHSCOPE_REGION=intl / DASHSCOPE_BASE_URL select the endpoint,
  matching the variable names proposed in OpenMontageInc#584.
- Cost is reconciled against the output duration DashScope reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hoobnn
hoobnn requested a review from calesthio as a code owner October 4, 2026 03:16
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Adds the faster wan3.0-video-prime model alongside wan3.0-video, with
per-model pricing. Both cost tables now use the Singapore list price,
the most expensive region per the official model pages, so the
estimate is a true upper bound; the earlier standard-model rates came
from a third-party source and ran ~4% under Singapore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@calesthio calesthio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding direct Wan 3.0 coverage. Both model IDs and the request family are documented, and all 26 focused mocked tests pass. Paid-job recovery and current endpoint setup need correction.

[P1] Resume accepted jobs without a new paid submission. execute always POSTs, accepts no task_id/resume input, and advertises timeout as retryable with max_retries=2. Although failure results sometimes retain task_id, invoking the tool again creates a second paid task while the first may still complete. Persist acceptance, add a query/download-only resume path and disable submission retries; report unknown actual billing as unknown rather than the default zero. Test timeout, lost POST response and download failure without duplicate POSTs.

[P2] Update the default endpoint/setup to the current workspace contract. The current Wan 3.0 reference specifies workspace-ID regional maas.aliyuncs.com URLs, while this adapter defaults to dashscope.aliyuncs.com/dashscope-intl.aliyuncs.com and documents only the existing API key. Implement/document the workspace-specific endpoint, or provide maintained compatibility evidence for the legacy default. Current official guidance also explicitly says not to recreate accepted tasks.

No paid generation was performed.

Save accepted Wan 3.0 job metadata before polling and disable submission retries. Use the configured Model Studio workspace endpoint and keep costs unknown when usage is missing.
@hoobnn

hoobnn commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the review. Both points are addressed in 569c3d9 (already on this branch).

P1 – accepted jobs are resumable, no re-submission

  • retry_policy is now max_retries=0; the timeout/rate-limit retry is gone.
  • Once the POST is accepted, the job metadata (task_id, endpoint, model, operation, parameters) is saved via save_job(job_path, …) before polling, and is also returned as resume_job in every result, including failures.
  • New resume path: execute({"resume_job": job}) (or operation="resume") only queries and downloads and never POSTs. The job is validated against the configured endpoint, model and task_id format. An invalid one fails without any request. estimate_cost is 0 for resume.
  • A lost or ambiguous POST response (5xx, timeout, bad task_id) returns status="submission_unknown" and tells the caller to check the original task before submitting again.
  • Cost is None (unknown) unless DashScope reports usage duration. The default 0 is gone.
  • Tests cover timeout, lost POST response and download failure. Each asserts exactly one POST, and the resume only issues GETs.

P2 – workspace endpoint

  • Default endpoint is now https://{DASHSCOPE_WORKSPACE_ID}.{region}.maas.aliyuncs.com. DASHSCOPE_REGION defaults to cn-beijing, and intl maps to ap-southeast-1. DASHSCOPE_BASE_URL still overrides it.
  • A missing or invalid workspace ID makes the tool report unavailable. .env.example, docs/PROVIDERS.md and the dashscope skill document the new variables.

Local check: tests/contracts dashscope/provider/registry subset passes (239 passed). No paid generation was run.

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