消费级视频生成(imagegen 同构镜像):durationSec 域(set/range)、ratio、首帧 imageUrls、audioUrl 受理面 = face.media 在场恒胜词表;owner 与终端用户日秒数配额(秒 = 计费口径);按实产秒数结算(purpose=videogen);同步径长等分钟级——推荐异步任务径;体帽 32MB;请求签名三头可选
const url = 'https://api.tansr.com/t1/videogen';const options = { method: 'POST', headers: { 'x-tansr-key-id': '<x-tansr-key-id>', 'x-tansr-key': '<x-tansr-key>', 'Content-Type': 'application/json' }, body: '{"model":"example","prompt":"example","negativePrompt":"example","duration":1,"ratio":"example","seed":1,"imageUrls":["example"],"audioUrl":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tansr.com/t1/videogen \ --header 'Content-Type: application/json' \ --header 'x-tansr-key: <x-tansr-key>' \ --header 'x-tansr-key-id: <x-tansr-key-id>' \ --data '{ "model": "example", "prompt": "example", "negativePrompt": "example", "duration": 1, "ratio": "example", "seed": 1, "imageUrls": [ "example" ], "audioUrl": "example" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”签名时间戳(unix 秒,十进制串;T-A34):与服务器时钟偏差 >300s → 401 signature_invalid
签名随机数(≥16 字符;T-A34):同 keyId 600s 窗内重现 → 401 nonce_replayed
请求签名(hex 小写;T-A34):HMAC-SHA256(K=sha256(SK 明文) 原始摘要, TWP1-HMAC-SHA256\n{METHOD}\n{path+query}\n{ts}\n{nonce}\n{sha256hex(rawBody)});三头须同现,在场恒校验;app signRequired 或 TANSR_API_TWP_REQUIRE_SIGNATURE=1 时未签名恒 401 signature_invalid
Request Bodyrequired
Section titled “Request Bodyrequired”object
视频模型引用名(候选池三级收敛产物;池外/越权恒 403 model_not_authorized,不泄露池存在性)。缺席 = 授权集顺位第一(与 bundle platformModels.videoGen 首行恒同);空授权集恒 videogen_not_configured
正向提示词(平台恒不落日志不落库;wire 帽 10000 = wan3.0 档,上游按模型限长再截)
反向提示词(dashscope 系上限 500 字符,超限上游自截)
视频时长(秒;缺省 5 = 上游缺省档)。费用 = 每秒单价 × 时长,预扣按此上界;wire 帽 30 = wan3.0 档,超模型帽静默钳
宽高比(如 16:9/9:16/1:1;wan3.0 另支持 adaptive;缺省随模型;合法域随模型,越域由上游 400 如实回)
随机种子(内容相对稳定;缺省上游随机)
输入图像(i2v 首帧;seedance 支持首帧+尾帧两张;公网 URL 或 data:image/*;base64 URI)。受理与形态域随模型,不受理的模型在场即 400
参考音频公网 URL(wan2.5/2.6 i2v 可选;超视频时长截断)。不受理的模型在场即 400
Examplegenerated
{ "model": "example", "prompt": "example", "negativePrompt": "example", "duration": 1, "ratio": "example", "seed": 1, "imageUrls": [ "example" ], "audioUrl": "example"}Responses
Section titled “Responses”视频产物(成功即扣)
object
请求 model 回显(S-G1 缺省径 = 生效模型 canonical handle,调用方由此得知实际所用模型)
成功视频直链(dashscope 口径 24h 有效 MP4,及时转存;上游单任务恒 1 条)
object
成功条数(上游单任务恒 1;全败恒不到达本响应)
计费秒数 = 上游成功报量(usage.duration)钳请求时长上界;per_second 行 cost = 每秒单价 × 本数(token 计价行如 seedance 按上游报量 token 结算,本位仅时长事实)
Examplegenerated
{ "model": "example", "videos": [ { "url": "example" } ], "videoCount": 1, "billedSeconds": 1}Videogen_not_configured(平台面未开通 / 解出三闸 wire·价格·凭据任一不过 fail-closed)/ bad_request(durationSec 域外、ratio 域外、i2v 首帧缺失、audioUrl 不受理等,detail 可解释)
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}App_key_invalid / 令牌无效或过期 / signature_invalid / nonce_replayed(T-A34)
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Insufficient_balance(预扣 fail-closed 零上游)
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Model_not_authorized(点名池外/越权,不泄露池存在性)/ forbidden(令牌径能力位 platform.* 未开,detail.capability)/ app_disabled / app_ip_denied
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Rate_limited(key 级 60s 窗)/ videogen_quota_exceeded(平台日顶或终端用户日配额档,UTC+8 日界,detail.limit/used)
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}Upstream_error(上游拒绝/形状非法;方言正文不透传,仅 detail.upstreamCode 机器码 + upstreamStatus)
object
object
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}本文是否有帮助?
感谢反馈,我们会持续改进这篇文章。