About
Qwen-Audio 3.1 TTS Flash is the fast Qwen-Audio 3.1 speech synthesis model on Alibaba Cloud Model Studio, available from the Singapore and China (Beijing) regions; besides the main languages it accepts the other language hint for about 50 more. It accepts natural-language instructions for dialect, emotion or role, and emotion and nonverbal tags such as [excited], [whispers] or [laughing] in the text. Infron serves it through the OpenAI-compatible POST /v1/audio/speech endpoint with mp3, wav, pcm or opus output, adjustable sample rate, speed, pitch and volume, and optional streaming. Requests are billed per text input token and audio output token.
1. Calling the API
Setup your API Key
To begin using Infron, create an account and generate your API Key.
export INFRON_KEY="YOUR_API_KEY"
Submit a request
Send JSON to POST https://llm.onerouter.pro/v1/audio/speech with your Infron API key. The request and response follow the OpenAI speech API, so the OpenAI SDKs work with the base URL https://llm.onerouter.pro/v1. The examples use the Alibaba Cloud voice longanhuan_v3.1. Replace YOUR_API_KEY with your key.
curl
curl https://llm.onerouter.pro/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "qwen/qwen-audio-3.1-tts-flash/text-to-audio",
"voice": "longanhuan_v3.1",
"input": "Hello! Welcome to Infron.",
"response_format": "mp3"
}' \
--output speech.mp3
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://llm.onerouter.pro/v1",
api_key="YOUR_API_KEY",
)
with client.audio.speech.with_streaming_response.create(
model="qwen/qwen-audio-3.1-tts-flash/text-to-audio",
voice="longanhuan_v3.1",
input="Hello! Welcome to Infron.",
response_format="mp3",
) as response:
response.stream_to_file("speech.mp3")
TypeScript (OpenAI SDK)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://llm.onerouter.pro/v1",
apiKey: "YOUR_API_KEY",
});
const response = await client.audio.speech.create({
model: "qwen/qwen-audio-3.1-tts-flash/text-to-audio",
voice: "longanhuan_v3.1",
input: "Hello! Welcome to Infron.",
response_format: "mp3",
});
fs.writeFileSync("speech.mp3", Buffer.from(await response.arrayBuffer()));
Response
A successful request returns HTTP 200 with the audio file as the body, not JSON. Content-Type follows response_format: audio/mpeg for mp3, audio/wav for wav, audio/pcm for pcm, audio/opus for opus. The examples above save it as speech.mp3.
Streaming
Add "stream_format": "sse" to receive Server-Sent Events while the audio is generated. Each speech.audio.delta event carries the next base64 chunk of the audio in response_format; decode the chunks and append them in order. The stream ends with a speech.audio.done event that reports usage.
curl https://llm.onerouter.pro/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "qwen/qwen-audio-3.1-tts-flash/text-to-audio",
"voice": "longanhuan_v3.1",
"input": "Hello! Welcome to Infron.",
"response_format": "mp3",
"stream_format": "sse"
}' \
--no-buffer
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}
data: {"type":"speech.audio.done","usage":{"input_tokens":9,"output_tokens":52,"total_tokens":61}}
The usage values are an example.
Routing and usage
This model is served by alibaba/cn (Alibaba Cloud Beijing) and alibaba/sg (Alibaba Cloud Singapore), at different prices (see Detailed Pricing). Infron routes each request to an available endpoint; to use one region only, add "provider": {"only": ["alibaba/sg"], "allow_fallbacks": false} to the request body (in extra_body with the Python SDK). Billing uses the text input tokens and audio output tokens that Alibaba Cloud reports. The audio response carries no usage; with streaming, speech.audio.done reports the text tokens as usage.input_tokens and the audio tokens as usage.output_tokens.
Errors
Parameters this model does not accept are rejected with HTTP 400 before the request is sent to Alibaba Cloud, and nothing is charged. error.message explains the problem and ends with the request ID:
{
"error": {
"message": "voice is required (DashScope voice id) (request id: 20261111221810441285700pZnPkvCJ)",
"type": "infron_ai_error",
"param": "",
"code": "invalid_request_error"
}
}
Errors reported by Alibaba Cloud, such as an unknown voice ID, are returned with Alibaba Cloud's message. If a stream fails after it has started, an error event is sent instead of speech.audio.done.
2. Schema
Input
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | Yes | -- | qwen/qwen-audio-3.1-tts-flash/text-to-audio | Model ID. |
input | string | Yes | -- | -- | Text to synthesize. Emotion and nonverbal tags such as [excited], [sad], [whispers], [laughing] or [sighing] can go in the text; SSML needs enable_ssml: true. |
voice | string | Yes | -- | -- | Alibaba Cloud voice ID, for example longanhuan_v3.1. Use a system voice listed for this model in Model Studio, or a cloned or designed voice bound to it. |
response_format | string | No | mp3 | mp3, wav, pcm, opus | Audio format. |
speed | number | No | 1 | 0.5 to 2.0 | Speaking rate. Sent as rate. |
instructions | string | No | -- | -- | Natural-language control of dialect, emotion or role, e.g. Speak slowly and clearly. Sent as instruction. |
language | string | No | -- | zh, en, fr, de, ja, ko, ru, pt, th, id, vi, es, it, ms, fil, ar, other | Language hint. Sent as the first element of language_hints. |
sample_rate | integer | No | 22050 | 8000, 12000, 16000, 22050, 24000, 44100, 48000; opus: 8000, 12000, 16000, 24000, 48000 | Output sample rate. |
bit_rate | integer | No | 32 | 6 to 510 (kbps) | Opus bitrate; only with response_format opus. |
stream_format | string | No | audio | audio, sse | sse streams Server-Sent Events (see Streaming). |
Alibaba Cloud fields
These fields are not part of the OpenAI speech API. Put them at the top level of the JSON body; with the OpenAI Python SDK pass them in extra_body.
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
volume | integer | No | 50 | 0 to 100 | Volume. |
pitch | number | No | 1 | 0.5 to 2.0 | Pitch multiplier. |
seed | integer | No | 0 | 0 to 65535 | Random seed for synthesis. |
enable_ssml | boolean | No | -- | true, false | Treat input as SSML. |
language_hints | array | No | -- | One language code | Language hint array; only the first element is used. Replaces language. |
hot_fix | object | No | -- | -- | Pronunciation and replacement fixes: pronunciation (word to pinyin) and replace (text to text). |
Unsupported fields
| Field | Behavior |
|---|---|
text_normalization | Ignored. |
| Other fields | Not forwarded to Alibaba Cloud (for example word_timestamp_enabled and the AIGC tag fields). |
Output
| Parameter | Type | Range | Description |
|---|---|---|---|
| Response body | binary | mp3, wav, pcm, opus | The audio file in response_format (without stream_format=sse). |
Content-Type header | string | audio/mpeg, audio/wav, audio/pcm, audio/opus | MIME type of the audio. |
type | string | speech.audio.delta, speech.audio.done, error | Streaming event type. |
audio | string | Base64 | Next chunk of the audio (speech.audio.delta). |
usage.input_tokens | integer | Non-negative | Text input tokens (speech.audio.done). |
usage.output_tokens | integer | Non-negative | Audio output tokens. |
usage.total_tokens | integer | Non-negative | Sum of input and output. |
error | object | -- | message, type and code of a failure (error event). |
3. Detailed Pricing
| Model | Endpoint | Billing unit | Input (text) | Output (audio) |
|---|---|---|---|---|
| Qwen: Qwen Audio 3.1 TTS Flash | alibaba/cn | Per 1M tokens | $0.212 | $1.696 |
| Qwen: Qwen Audio 3.1 TTS Flash | alibaba/sg | Per 1M tokens | $0.23 | $1.87 |
Prices are in USD. Billing uses the text input tokens and audio output tokens that Alibaba Cloud reports.
Sources: Qwen-Audio-TTS HTTP API, Speech synthesis overview, Pricing.