音频
使用已配置的 OpenAI 兼容音频接口,以及 Qwen 原生声音复刻与 TTS。
路径
| 路径 | 方法 | 状态 |
|---|---|---|
| /v1/audio/transcriptions | POST | 可用 |
| /v1/audio/translations | POST | 可用 |
| /v1/audio/speech | POST | 可用 |
POST /v1/audio/speech
从文本输入生成语音音频。请求使用兼容 OpenAI 的音频语音 JSON 结构,并可在配置允许时接受 model、input、voice、response format、speed、instructions、metadata 及供应商专用的转发字段。
curl https://www.token168.cc/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-d '{
"model": "<MODEL_ID>",
"input": "Token168 unifies native model APIs.",
"voice": "alloy",
"instructions": "Neutral narration.",
"response_format": "mp3",
"speed": 1,
"stream_format": "none",
"metadata": {"trace_id": "trace_123"},
"task_type": "tts",
"language": "en",
"ref_audio": "",
"ref_text": "",
"x_vector_only_mode": false,
"max_new_tokens": 1024,
"initial_codec_chunk_frames": 0
}'
POST /api/v1/services/audio/tts/customization
使用 model=voice-enrollment、action=create_voice 创建音色,参考录音支持公网 URL 或 Base64 Data URI。保存阿里返回的原始 output.voice_id。音色管理操作免费。
curl https://www.token168.cc/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "create_voice",
"target_model": "qwen-audio-3.1-tts-plus",
"prefix": "myvoice",
"audio": "https://example.com/reference.wav",
"language_hints": [
"zh"
]
}
}'
query_voice
使用返回的 voice_id 调用 query_voice,状态为 OK 后再合成。同一个 customization 接口也支持 list_voice、update_voice 和 delete_voice。
curl https://www.token168.cc/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "query_voice",
"voice_id": "VOICE_ID_FROM_CREATE"
}
}'
POST /api/v1/services/audio/tts/SpeechSynthesizer
使用 qwen-audio-3.1-tts-plus,将原始 voice_id 填入 input.voice。非流式返回 output.audio.url;增加 X-DashScope-SSE: enable 后,按顺序接收 output.audio.data 中的 Base64 音频块。按最终 usage.characters 计费,不按 Token 重复计费。这些接口使用 Token168 API Key。
curl https://www.token168.cc/api/v1/services/audio/tts/SpeechSynthesizer \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-audio-3.1-tts-plus",
"input": {
"text": "你好,欢迎使用语音合成。",
"voice": "VOICE_ID_FROM_CREATE",
"format": "wav",
"sample_rate": 24000
}
}'
cosyvoice-v3-plus
使用 cosyvoice-v3-plus,input.voice 填受支持的系统音色,例如 longanyang。沿用同一个语音合成接口,用 Token168 API Key 鉴权。JSON 返回有有效期的 output.audio.url。加 X-DashScope-SSE: enable 可接收有序的 Base64 音频块,按末帧 usage.characters 计费。每次请求最多输入 20,000 字符。
curl https://www.token168.cc/api/v1/services/audio/tts/SpeechSynthesizer \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cosyvoice-v3-plus",
"input": {
"text": "你好,欢迎使用语音合成。",
"voice": "longanyang",
"format": "wav",
"sample_rate": 24000
}
}'
POST /v1/audio/transcriptions
使用 qwen3-asr-flash 转录单个音频文件。必填 model、file,可选 language、prompt、response_format(json 或 text)。单文件不超过 7 MiB、5 分钟;该型号不支持流式、字幕、input 和 speed 参数。
curl https://www.token168.cc/v1/audio/transcriptions \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-F model="qwen3-asr-flash" \
-F file="@speech.wav" \
-F response_format="json" \
-F language="en"
POST /v1/audio/translations
通过兼容 OpenAI 的音频转发将上传的音频翻译为英文文本。其 multipart 结构与转录相同,由路由选择翻译专用的上游行为。
curl https://www.token168.cc/v1/audio/translations \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-F model="<MODEL_ID>" \
-F file="@speech.wav" \
-F input="speech.wav" \
-F response_format="json" \
-F language="en" \
-F speed="1"
范围
型号可用性和价格以模型目录为准。Qwen 原生接口保留供应商 JSON 和 SSE 格式;实时语音和音乐使用各自接口。