Voice cloning HTTP API: Qwen-Audio and CosyVoice
HTTP parameters, responses, and examples for cloning and managing Qwen-Audio and CosyVoice voices.
This reference covers Qwen-Audio-TTS, Qwen-Audio-Realtime, and CosyVoice.
First Obtain API Key and Configure Environment Variables. Request examples read from DASHSCOPE_API_KEY. When managing the same voice across different APIs, use the same account.
For SDK definitions, see Java SDK and Python SDK.
Service endpoint
China (Beijing)
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization
Singapore
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/audio/tts/customization
Replace {WorkspaceId} with the actual Workspace ID; this can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The API Keys for Beijing and Singapore differ.
ImportantAlibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing) and Singapore regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
- North China 2 (Beijing) Region: Migrate from
dashscope.aliyuncs.comto{WorkspaceId}.cn-beijing.maas.aliyuncs.com. - Singapore Region: Migrate from
dashscope-intl.aliyuncs.comto{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com.
Existing domain names remain fully functional.
Request headers
AuthorizationstringRequired: YesAuthentication token in the format Bearer <your_api_key>. Replace <your_api_key> with your actual API key.
Content-TypestringRequired: YesSet to application/json.
Audio Requirements and Costs
Refer to the Voice Cloning User Guide for audio requirements. The cloning process for Qwen-Audio-Realtime is described in Real-time voice conversation Voice Cloning. Creating a voice with Qwen-Audio-Realtime is free; model invocation is billed according to the target model, details in Billing Information, and quantity limits are outlined in Quota Information.
Request body
modelstring— Required
Set to voice-enrollment.
inputobject— Required
Properties
actionstring— Required
Operation:
create_voice: Create a voice.list_voice: List voices.query_voice: Get voice details.update_voice: Update a voice.delete_voice: Delete a voice.
target_modelstring— Required for creation
The model that will use the voice. It must match the model used in subsequent synthesis or conversation calls; otherwise, the call fails.
Choose a Qwen-Audio-TTS, Qwen-Audio-Realtime, or CosyVoice model that supports voice cloning. See Supported models for model IDs and regions.
audiostring— Required for creation or update when url is not provided
Reference audio for creation, or new reference audio for an update. Accepts a publicly accessible URL or a Base64 Data URI, such as data:audio/wav;base64,....
NoteCompatible with the legacy parameter url; when using url, audio may be omitted. url will be phased out; it is recommended to switch to audio.
prefixstring— Required for creation; optional when listing voices
For creation: Voice name prefix. Allowed characters are digits and English letters, up to 10 characters. The generated voice name has the format {target_model}-{prefix}-{unique_identifier}.
When listing voices: Filters voices by name prefix.
language_hintsarray[string]— Optional for creation
Auxiliary model to identify the language of the sample audio, enabling more accurate extraction of voice characteristics and improving cloning performance. If the specified language does not match the actual audio language (e.g., setting en for Chinese audio), the system will ignore this setting and automatically detect the language.
This parameter is an array, and its length must be 1.
NoteApplicable to qwen-audio-3.1-tts-plus, qwen-audio-3.1-tts-flash, qwen-audio-3.0-tts-plus, qwen-audio-3.0-tts-flash, qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, qwen-audio-3.0-realtime-flash, cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, cosyvoice-v3-plus, cosyvoice-v3-flash.
Click to view the languages supported by each model
-
qwen-audio-3.1-tts-plus、qwen-audio-3.1-tts-flash、qwen-audio-3.0-tts-plus、qwen-audio-3.0-tts-flash、qwen-audio-3.1-realtime-plus、qwen-audio-3.1-realtime-flash、qwen-audio-3.0-realtime-plus、qwen-audio-3.0-realtime-flash:
- zh: Chinese
- en: English
- fr: French
- de: German
- ja: Japanese
- ko: Korean
- ru: Russian
- pt: Portuguese
- th: Thai
- id: Indonesian
- vi: Vietnamese
- it: Italian
- es: Spanish
- ms: Malay
- fil: Filipino
- ar: Arabic
-
cosyvoice-v3-plus:
- zh: Chinese
- en: English
- fr: French
- de: German
- ja: Japanese
- ko: Korean
- ru: Russian
-
cosyvoice-v3.5-plus、cosyvoice-v3.5-flash、cosyvoice-v3-flash:
- zh: Chinese
- en: English
- fr: French
- de: German
- ja: Japanese
- ko: Korean
- ru: Russian
- pt: Portuguese
- th: Thai
- id: Indonesian
- vi: Vietnamese
Default value: ["zh"].
max_prompt_audio_lengthfloat— Optional for creation
Maximum duration (in seconds) of the reference audio used for voice cloning after preprocessing. Value range: [3.0, 30.0].
Default value: 10.0.
NoteApplies to qwen-audio-3.1-tts-plus, qwen-audio-3.1-tts-flash, qwen-audio-3.0-tts-plus, qwen-audio-3.0-tts-flash, qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, qwen-audio-3.0-realtime-flash, cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, cosyvoice-v3-flash.
enable_preprocessboolean— Optional for creation
Whether to enable audio preprocessing (noise reduction, audio enhancement, and volume normalization). Enable this for recordings with background noise. Disable it for recordings in quiet environments to preserve the original voice characteristics.
Default: false.
NoteApplies to qwen-audio-3.1-tts-plus, qwen-audio-3.1-tts-flash, qwen-audio-3.0-tts-plus, qwen-audio-3.0-tts-flash, qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, qwen-audio-3.0-realtime-flash, cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, cosyvoice-v3-flash.
enable_volume_normalizationstring— Optional for creation
Whether to normalize the volume of the sample audio used for voice cloning. Values:
"true": Enable volume normalization."false": Disable volume normalization.
When enabled, the synthesized audio using the created voice may have a different volume compared to when this parameter is disabled.
Default value: "false".
page_indexinteger— Optional when listing voices
The page index.
page_sizeinteger— Optional when listing voices
The number of entries per page.
voice_idstring— Required to get, update, or delete a voice
The ID of the voice to get, update, or delete.
Request examples
Create
The example uses qwen-audio-3.1-tts-plus. Replace target_model in input with your actual target model ID.
The following configuration is for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_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://your-audio-url.wav",
"language_hints": ["zh"],
"enable_volume_normalization": "false"
}
}'
When using a local WAV audio file, you can generate a Base64 Data URI using the following code and set the value of audio in the audio field of the input object in the create or update request. Replace sample.wav with the path to your local audio file.
import base64
from pathlib import Path
audio = "data:audio/wav;base64," + base64.b64encode(
Path("sample.wav").read_bytes()
).decode("ascii")
List
The following configuration is for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "list_voice",
"prefix": "myvoice",
"page_size": 10,
"page_index": 0
}
}'
Get details
The following configuration is for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "query_voice",
"voice_id": "yourVoiceId"
}
}'
Update
The following configuration is for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "update_voice",
"voice_id": "yourVoiceId",
"audio": "https://new-audio-url.wav"
}
}'
Delete
The following configuration is for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration varies by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "voice-enrollment",
"input": {
"action": "delete_voice",
"voice_id": "yourVoiceId"
}
}'
Response body
request_idstringThe unique identifier of this request.
outputobjectContains the fields for creation, listing, or getting voice details. An empty object is returned for update or deletion.
Properties
voice_idstring— Returned for creation
Voice ID.
voice_listarray[object]— Returned when listing voices
List of voices found.
Properties
voice_idstringVoice ID.
target_modelstringThe target model driving the voice (text-to-speech or real-time speech conversation).
gmt_createstringThe time when the voice was created.
gmt_modifiedstringThe last modification time.
statusstringVoice status; see "Voice Status Description" for valid values.
resource_linkstring— Returned for voice details
The URL of the audio file.
gmt_createstring— Returned for voice details
The time when the voice was created.
gmt_modifiedstring— Returned for voice details
The last modification time.
statusstring— Returned for voice details
Voice status; see "Voice Status Description" for valid values.
target_modelstring— Returned for voice details
The target model driving the voice (text-to-speech or real-time speech conversation).
usageobjectUsage information for this request.
Properties
countintegerAlways 1. For voice creation, this is the number of voices created.
Response examples
Create
{
"output": {
"voice_id": "qwen-audio-3.1-tts-plus-myvoice-xxxxxx"
},
"usage": {
"count": 1
},
"request_id": "xxxx-xxxx-xxxx"
}
List
{
"output": {
"voice_list": [
{
"voice_id": "qwen-audio-3.0-tts-flash-myvoice-xxxxxx",
"target_model": "qwen-audio-3.0-tts-flash",
"gmt_create": "2024-12-11 13:38:02",
"gmt_modified": "2024-12-11 13:38:02",
"status": "OK"
}
]
},
"usage": {
"count": 1
},
"request_id": "xxxx-xxxx-xxxx"
}
Get details
{
"output": {
"gmt_create": "2024-12-11 13:38:02",
"resource_link": "https://yourAudioFileUrl",
"target_model": "qwen-audio-3.1-tts-plus",
"gmt_modified": "2024-12-11 13:38:02",
"status": "OK"
},
"usage": {
"count": 1
},
"request_id": "xxxx-xxxx-xxxx"
}
Update
{
"output": {},
"usage": {
"count": 1
},
"request_id": "xxxx-xxxx-xxxx"
}
Delete
{
"output": {},
"usage": {
"count": 1
},
"request_id": "xxxx-xxxx-xxxx"
}
Voice status descriptions
Created voices go through a review process.
| Status | Description |
|---|---|
DEPLOYING | Under review or processing. |
OK | Review passed. The voice is ready to use. |
UNDEPLOYED | Review rejected. The voice can't be used. |
Error messages
If you encounter any errors, please refer to Error Codes for troubleshooting.
The former MiniMax voice cloning reference has moved to MiniMax HTTP API.