fix(console): 视频输入上限按字段拆分并限制参考图生视频时长 - #909
Merged
Merged
Conversation
…to-video duration Upstream enforces the two video image inputs separately: image is a single first frame (image-to-video) and reference_images holds up to 7 references (reference-to-video). The combined ceiling of MaxInputImages (8) let 8 references pass the local guard and take a 400 from upstream instead: "Too many reference images: 8. Maximum allowed is 7." Generation also allowed 1-15s for every mode, but reference-to-video on grok-imagine-video caps at 10s upstream: "Duration 15s exceeds the maximum allowed for reference-to-video, which is 10s." image-to-video and grok-imagine-video-1.5 keep 15s, so the new guard keys on reference_images plus the base model rather than on duration alone. Both limits come straight from upstream error text, quoted in comments so future changes can be checked against them.
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在生产环境对 Console
POST /v1/videos/generations做了黑盒实测(grok-imagine-video与grok-imagine-video-1.5分别验证),发现两处本地守卫与上游实际行为不一致。#885 已把image/reference_images的互斥语义修好,本 PR 只补这两处数值与分档,不改字段语义、不改前端。改动 1:输入上限按字段拆分,不再求和
现状
consoleMaxVideoImages = mediadomain.MaxInputImages(= 8),且consoleVideoImageCount把image与reference_images合计计数。上游按字段各自设限:
reference_images上限 7,8 张回400 Too many reference images: 8. Maximum allowed is 7.(两个模型分别实测)image是单数字段,上限 1有了互斥校验之后合计口径不再致命,但 off-by-one 还在:8 张参考图能通过本地守卫,然后吃上游 400。
改为
consoleMaxVideoFirstFrames = 1/consoleMaxVideoReferenceImages = 7分别校验,consoleVideoImageCount改成consoleVideoImageCounts分字段返回。改动 2:reference-to-video 在基础模型上限 10 秒
现状生成一律放行 1–15s。上游有两个互斥的图片入口,走哪个字段决定时长上限:
image(image-to-video)reference_images(reference-to-video)v1 +
reference_images+ 15s 的上游报错原文:新增的守卫只拦
grok-imagine-video+ 有reference_images+duration > 10这一种组合,image-to-video 与 1.5 都保持 15s 不受影响。一点补充:
/v1/videos/generations是异步接口,create 入队即 200 +request_id,上游的参数拒绝只在轮询GET /v1/videos/{id}的status:failed里体现。我们 E2E 实跑过 v1 双图 15s,结果是任务 failed 且不扣额度,所以在本地拦掉比放过去更好。测试
TestConsoleVideoRejectsLongReferenceDurationOnBaseModel:v1 + 参考图 + 15s 被本地拒绝TestConsoleVideo15AllowsLongReferenceDuration:同样的请求在 1.5 上正常发到上游TestConsoleVideoRejectsTooManyReferenceImages/TestConsoleVideoRejectsTooManyCombinedImages改引用新常量,断言不变TestConsoleVideoRejectsImageWithReferences、TestConsoleVideoPostsSingleReferenceImage、TestConsoleVideo15Rejects1080pReferenceMode未改动且通过本地:
gofmtclean、go build ./...、go vet ./...通过;go test ./...全绿;console包 15 个 Video 用例全部 PASS。说明
两个上限值都直接来自上游报错文案,注释里写了报错原文和测法,便于以后上游调整时核对。
顺带一条复测提醒:Console 团队级限频较紧(实测约 60 RPM,
grok-imagine-video-1.5另有约 2 RPS),而且 429 的优先级高于图片数量校验(实测顺序:422 反序列化 → 404 模型不存在 → 429 配额 → 400 图片数量 → 400 图片元素 → 400 prompt 为空)。连发用例容易把配额错误误读成接口契约,建议每个用例换一个满额账号、间隔 ≥25 秒。