Request parameters and response fields for the non-realtime speech synthesis (Qwen-TTS) API.
Request body
- Non-streaming output
- Streaming output
- Python
- Java
- curl
In DashScope Python SDK 2.0, non-realtime speech synthesis is called through the client.audio.tts.http resource.
Shell quoting corrections
These examples preserve all request values and use a quoted heredoc so apostrophes in the JSON text are passed literally.Corrected streaming request
| Parameter | Type | Description |
|---|---|---|
| model | string | (required) The model name. For details, see Supported models. |
| input | object | (required) Input parameters. |
| input.text | string | (required) The text to synthesize. Supports multilingual mixed input. The maximum input length is 600 characters. |
| input.voice | string | (required) The voice to use. See Supported system voices. |
| input.language_type | string | (optional) The language of the synthesized audio. Defaults to Auto. Use Auto for multilingual or undetermined input, or specify Chinese, English, German, Italian, Portuguese, Spanish, Japanese, Korean, French, or Russian for better single-language synthesis. |
Response object (streaming and non-streaming formats are identical)
| Parameter | Type | Description |
|---|---|---|
| request_id | string | A unique identifier for this request. Use it for troubleshooting. |
| status_code | integer | The HTTP status code as defined in RFC 9110. Common values: • 200: Request succeeded.• 400: Invalid request parameters.• 401: Unauthorized.• 404: Resource not found.• 500: Internal server error. |
| code | string | The error code returned on failure. See Error codes. |
| message | string | The error message returned on failure. See Error codes. |
| usage | object | Character usage for this request. |
| usage.output_tokens | integer | Output-audio token usage. Always 0 for Qwen3-TTS-Flash. |
| usage.input_tokens | integer | Input-text token usage. Always 0 for Qwen3-TTS-Flash. |
| usage.characters | integer | Number of input characters. Returned only by Qwen3-TTS-Flash. |
| output | object | The model output. |
| output.text | string | Always null. Ignore this field. |
| output.choices | string | Always null. Ignore this field. |
| output.finish_reason | string | The generation status:
|
| output.audio | object | The audio output from the model. |
| output.audio.url | string | The URL of the complete audio file, valid for 24 hours. In non-streaming mode, returned directly in the response. In streaming mode, only returned in the last chunk of the SSE stream (intermediate chunks do not contain this field). |
| output.audio.data | string | Base64-encoded audio data. In non-streaming mode, this field is always an empty string (use url to get the complete audio file). In streaming mode, intermediate chunks contain Base64-encoded audio segments, while the last chunk returns an empty string (use url to get the complete audio). |
| output.audio.id | string | A unique identifier for the audio. |
| output.audio.expires_at | integer | The URL expiration time as a Unix timestamp. |
Audio download and playback
Before running the examples, obtain and configure an API key and install the DashScope SDK. The Python playback example also requires PyAudio and NumPy. See the code comments for PyAudio installation instructions, and install NumPy with pip install numpy.
Download audio (Java)
You must import the Gson dependency. Add it using Maven or Gradle:
- Maven
- Gradle
Add the following to
pom.xml:Streaming playback
- Python
- Java