/t1/videogen 异步提交:预备链(认证/能力位/解出/受理/配额/预扣)与同步端点同一函数——校验失败在本响应即时可见恒不产失败任务行;通过即落 media_tasks 行并后台执行,202 携 taskId/status=queued/pollIntervalMs;计费语义同同步径(成功即扣,断连照常产出照常扣费,有找回径不亏);params 快照恒不含用户内容
const url = 'https://api.tansr.com/t1/videogen/tasks';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/tasks \ --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”已受理({taskId, status:“queued”, model, pollIntervalMs})
object
任务 id(ULID;GET /t1/{videogen,imagegen}/tasks/:id 找回锚)
生效模型引用名(同步端点 model 回显同语义;缺省径 = 顺位第一 canonical handle)
建议轮询间隔毫秒(服务端上游轮询同拍;更密只耗限额不提速)
找回窗截止(ISO;窗外查询恒 404。产出直链另受上游 ~24h 失效约束,及时转存)
Example
{ "status": "queued"}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" }}本文是否有帮助?
感谢反馈,我们会持续改进这篇文章。