Skip to main content

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)
  • Singapore
POST https://{WorkspaceId}.cn-beijing.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.
Alibaba 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.com to {WorkspaceId}.cn-beijing.maas.aliyuncs.com.
  • Singapore Region: Migrate from dashscope-intl.aliyuncs.com to {WorkspaceId}.ap-southeast-1.maas.aliyuncs.com.
Existing domain names remain fully functional.

Request headers

AuthorizationstringRequired: Yes
Authentication token in the format Bearer <your_api_key>. Replace <your_api_key> with your actual API key.
Content-TypestringRequired: Yes
Set 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
— RequiredSet to voice-enrollment.
inputobject
— Required
actionstring
— RequiredOperation:
  • 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 creationThe 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 providedReference 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,....
Compatible 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 voicesFor 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 creationAuxiliary 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.
Applicable 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.
  • 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 creationMaximum duration (in seconds) of the reference audio used for voice cloning after preprocessing. Value range: [3.0, 30.0].Default value: 10.0.
Applies 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 creationWhether 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.
Applies 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 creationWhether 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 voicesThe page index.
page_sizeinteger
— Optional when listing voicesThe number of entries per page.
voice_idstring
— Required to get, update, or delete a voiceThe ID of the voice to get, update, or delete.

Request examples

  • Create
  • List
  • Get details
  • Update
  • Delete
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")

Response body

request_idstring
The unique identifier of this request.
outputobject
Contains the fields for creation, listing, or getting voice details. An empty object is returned for update or deletion.
voice_idstring
— Returned for creationVoice ID.
voice_listarray[object]
— Returned when listing voicesList of voices found.
voice_idstring
Voice ID.
target_modelstring
The target model driving the voice (text-to-speech or real-time speech conversation).
gmt_createstring
The time when the voice was created.
gmt_modifiedstring
The last modification time.
statusstring
Voice status; see "Voice Status Description" for valid values.
resource_linkstring
— Returned for voice detailsThe URL of the audio file.
gmt_createstring
— Returned for voice detailsThe time when the voice was created.
gmt_modifiedstring
— Returned for voice detailsThe last modification time.
statusstring
— Returned for voice detailsVoice status; see "Voice Status Description" for valid values.
target_modelstring
— Returned for voice detailsThe target model driving the voice (text-to-speech or real-time speech conversation).
usageobject
Usage information for this request.
countinteger
Always 1. For voice creation, this is the number of voices created.

Response examples

  • Create
  • List
  • Get details
  • Update
  • Delete
{
    "output": {
        "voice_id": "qwen-audio-3.1-tts-plus-myvoice-xxxxxx"
    },
    "usage": {
        "count": 1
    },
    "request_id": "xxxx-xxxx-xxxx"
}

Voice status descriptions

Created voices go through a review process.
StatusDescription
DEPLOYINGUnder review or processing.
OKReview passed. The voice is ready to use.
UNDEPLOYEDReview 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.