跳转到内容

/t1/tts 异步提交:预备链(认证/能力位/解出/受理/配额/预扣)与同步端点同一函数——校验失败在本响应即时可见恒不产失败任务行;通过即落 media_tasks 行并后台执行,202 携 taskId/status=queued/pollIntervalMs;计费语义同同步径(成功即扣,断连照常产出照常扣费,有找回径不亏);params 快照恒不含用户内容

POST
/t1/tts/tasks
curl --request POST \
--url https://api.tansr.com/t1/tts/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", "input": "example", "voice": "example", "format": "wav", "speed": 1 }'
x-tansr-ts
string
/^\d{1,15}$/

签名时间戳(unix 秒,十进制串;T-A34):与服务器时钟偏差 >300s → 401 signature_invalid

x-tansr-nonce
string
>= 16 characters <= 128 characters

签名随机数(≥16 字符;T-A34):同 keyId 600s 窗内重现 → 401 nonce_replayed

x-tansr-sign
string
/^[0-9a-f]{64}$/

请求签名(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

Media typeapplication/json
object
model

文字转语音模型引用名(候选池收敛产物;池外/越权恒 403 model_not_authorized)。缺席 = 授权集顺位第一(与 bundle platformModels.textToSpeech 首行恒同);空授权集恒 tts_not_configured

string
>= 1 characters <= 128 characters
input
required

合成文本(≤ 面档 maxChars,平台缺省帽 2000;字符口径同上游计费:1 个汉字计 2,其余各计 1;超帽 400 携 maxChars/chars;恒不落日志/库)

string
>= 1 characters <= 20000 characters
voice

音色 id(缺席 = 面档 defaultVoice;非面档音色 → 400 携可选音色表)

string
>= 1 characters <= 64 characters
format
Any of:
string
Allowed value: wav
speed

语速倍率(仅面档 speed 域在场的家族受理,域外 400;dashscope 无位在场即 400)

number
>= 0.1 <= 5

已受理({taskId, status:“queued”, model, pollIntervalMs})

Media typeapplication/json
object
taskId
required

任务 id(ULID;GET /t1/{videogen,imagegen}/tasks/:id 找回锚)

string
status
required
Any of:
string
Allowed value: queued
model
required

生效模型引用名(同步端点 model 回显同语义;缺省径 = 顺位第一 canonical handle)

string
pollIntervalMs
required

建议轮询间隔毫秒(服务端上游轮询同拍;更密只耗限额不提速)

integer
retainedUntil
required

找回窗截止(ISO;窗外查询恒 404。产出直链另受上游 ~24h 失效约束,及时转存)

string
Example
{
"status": "queued"
}

Tts_not_configured(平台面未开通 / 解出三闸 wire·价格·凭据任一不过 fail-closed)/ bad_request(input 空白或超面档 maxChars(detail.maxChars/chars,汉字计 2)/ 非面档音色(detail.voices/defaultVoice)/ speed 域外或家族无位)

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}

App_key_invalid / 令牌无效或过期 / signature_invalid / nonce_replayed(T-A34)

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}

Insufficient_balance(预扣 fail-closed 零上游)

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}

Model_not_authorized(点名池外/越权,不泄露池存在性)/ forbidden(令牌径能力位 platform.* 未开,detail.capability)/ app_disabled / app_ip_denied

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}

Rate_limited(key 级 60s 窗)/ tts_quota_exceeded(平台日顶或终端用户日配额档,UTC+8 日界,detail.limit/used)

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}

Upstream_error(上游拒绝/形状非法;方言正文不透传,仅 detail.upstreamCode 机器码 + upstreamStatus)

Media typeapplication/json
object
error
required
object
code
required

错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)

string
Allowed values: adjudicator_not_authorized admin_forbidden admin_key_invalid app_disabled app_ip_denied app_key_invalid approval_self_forbidden asr_not_configured asr_quota_exceeded auth_channel_undelivered bad_request conflict content_blocked context_window_exceeded currency_not_supported device_code_denied device_code_expired device_code_pending device_code_slow_down egress_blocked endpoint_disabled envelope_key_undelivered fence_denied forbidden idempotency_conflict idp_untrusted image_not_supported imagegen_not_configured imagegen_quota_exceeded insufficient_balance internal_error invalid_api_key license_required limit_exceeded liquidation_not_enabled model_not_authorized model_not_found nonce_replayed not_found order_state_invalid org_byok_not_available org_ceiling_exceeded otp_invalid otp_rate_limited pay_amount_mismatch pay_channel_undelivered pay_signature_invalid payload_too_large payment_required plan_apps_exceeded plan_concurrency_exceeded plan_end_users_exceeded plan_gate_unavailable plan_members_exceeded plan_required plan_tier_insufficient policy_locked pool_signing_undelivered preflight_required pricing_guard_tripped principal_required protocol_unsupported quota_exceeded rate_limited refund_not_eligible section_not_deliverable session_archived signature_invalid stream_backpressure token_expired tts_not_configured tts_quota_exceeded unauthorized upstream_connect_timeout upstream_disconnected upstream_error upstream_idle_timeout upstream_timeout upstream_total_timeout upstream_ttfb_timeout validation_failed videogen_not_configured videogen_quota_exceeded websearch_not_configured websearch_quota_exceeded
message
required
string
requestId
required
string
detail
object
Example
{
"error": {
"code": "adjudicator_not_authorized"
}
}