Qwen-Audio-ASR HTTP API
Submit an audio file as a public URL or a Base64 data URI to get a transcript and word-level timestamps. Receive the result in a single response or stream it over SSE.
NoteThe examples use China (Beijing). Replace {WorkspaceId} with your workspace ID and set DASHSCOPE_API_KEY to an API key for that region.
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generationRequest headers
AuthorizationstringRequiredUse the API key for the endpoint region, in the format Bearer <API Key>.
Content-TypestringRequiredThe media type of the request body. Fixed to application/json.
X-DashScope-SSEstringOptionalControls how the result is returned.
enable— Requests a streaming response. Parse the response according to itsContent-Type.text/event-stream— Read each SSE event and parse the content afterdata:as JSON.application/json— Parse the entire response as a single JSON object.
disableor omitted — Returns the final result in a single response.
Noteqwen-audio-3.0-asr-flash returns results over SSE only for audio that is at least 1 minute long.
Request body
modelstringRequiredThe model name.
inputobjectRequiredThe input information.
messagesarray[object]RequiredList of messages. Optional conversation history precedes the audio. The user message containing the audio must come last.
rolestringRequiredMessage role.
user(required): At least one user message must contain the audio to transcribe. Other user messages can supply context.assistant(optional): Supplies a previous model reply.
contentarray[object]RequiredThe message content list.
typestringRequiredChoose the content type for the message role. Include at least one input_audio item per request.
input_audio— Audio fromuser. Requires aninput_audioobject.input_text— Context fromuser. Requires thetextfield.text— Context fromassistant. Requires thetextfield.
input_audioobjectConditionally requiredRequired when type is input_audio.
datastringRequiredAudio to transcribe. Use either input format.
- Public URL — Provide a publicly accessible audio file URL, such as
https://example.com/audio/sample.wav. - Base64 Data URI — Specify the MIME type for the audio format and the Base64-encoded file contents, as in
data:audio/wav;base64,{BASE64_ENCODED_DATA}. For MP3, useaudio/mpeg. Base64 encoding increases the payload size. For file size and duration limits, see Audio specifications.
How to generate a Base64 data URI
The examples encode a local WAV file named sample.wav as a Base64 data URI. Pass the output directly to input_audio.data. To try the examples, use the sample WAV file.
import base64
from pathlib import Path
audio = Path("sample.wav").read_bytes()
print("data:audio/wav;base64," + base64.b64encode(audio).decode("ascii"))
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
public class Main {
public static void main(String[] args) throws Exception {
byte[] audio = Files.readAllBytes(Paths.get("sample.wav"));
System.out.println("data:audio/wav;base64," + Base64.getEncoder().encodeToString(audio));
}
}
textstringConditionally requiredContext text helps the model recognize domain-specific terms. See Context enhancement. Provide the following content according to type.
input_text— A transcript of a previous user turn or a list of domain terms relevant to the audio.text— A model reply from a previous turn.
Note
- Message count: Provide at most 5 context messages of each type (
input_textandtext). If this limit is exceeded, only the 5 most recent messages are kept. - Text length: The combined length of the
userandassistanttextfields in each turn must not exceed 400 characters. Each character counts as 1. Excess text is truncated from the end. - Message order: Arrange messages by conversation turn. Within each turn, the
usermessage (input_text) must precede its correspondingassistantmessage (text).
parametersobjectRequiredThe model parameters.
formatstringRequiredThe audio format. Set this to match your actual audio format. Supported values include wav, mp3, and opus. For details, see Audio specifications.
sample_ratestringOptionalThe audio sample rate, in Hz. For example, 16000 means a 16 kHz sample rate. For details, see Audio specifications.
speaker_diarization_enabledbooleanOptionalNoteApplies only to qwen-audio-3.1-asr-flash.
Specifies whether to enable speaker diarization. Default: false. When set to true, the response uses speaker_id to distinguish speakers and includes output.sentences. When diarization is enabled, keep_dialect and language_hints are ignored.
keep_dialectbooleanOptionalNoteApplies only to qwen-audio-3.1-asr-flash.
Whether to preserve dialect expressions.
false— Transcribe dialect speech as standard Mandarin text (default).true— Preserve dialect expressions.
language_hintsarray[string]OptionalSpecify language codes to improve recognition accuracy. Only the first four codes take effect. Omit this parameter when the language is unknown to enable automatic detection.
Supported language codes
zh: Chineseen: Englishja: Japaneseko: Koreanvi: Vietnameseth: Thaiid: Indonesianms: Malaytl: Filipinohi: Hindiar: Arabicfr: Frenchde: Germanes: Spanishpt: Portugueseru: Russianit: Italiannl: Dutchsv: Swedishda: Danishfi: Finnishno: Norwegianel: Greekpl: Polishcs: Czechhu: Hungarianro: Romanianbg: Bulgarianhr: Croatiansk: Slovak
qwen-audio-3.1-asr-flash also supports the following language codes:
tr: Turkishfa: Persianmr: Marathiml: Malayalamne: Nepaliky: Kyrgyzaz: Azerbaijanika: Georgianhy: Armeniansl: Sloveniansq: Albanianet: Estonianlv: Latvianlt: Lithuanianca: Catalaneu: Basquegl: Galicianor: Odiadv: Divehias: Assamesekmr: Northern Kurdishtig: Tigrefy: Western Frisianba: Bashkirbe: Belarusiantt: Tataria: Interlinguamhr: Meadow Maritok: Toki Pona
vocabulary_idstringOptionalThe ID of a precompiled hot word list.
Generate this ID in advance by calling the create hot word list API. Pass the ID during recognition to use the hot words in the list.
Suitable for scenarios where the vocabulary is known and relatively stable, and where you need to reuse the same word list across requests.
For usage details, see Precompiled hotwords.
vocabularyobjectOptionalUse instant hotwords to supply terms for this request without creating a vocabulary list. Each key is a term (string) and each value is its weight (integer), for example {"Kelira": 5}.
Supported hotword weights:
1–5— Higher weights make the model more likely to recognize the term.50— Marks a super hotword to substantially improve recall. Specify up to 50 super hotwords.
NoteWhen you supply both vocabulary_id and vocabulary, the service merges the two sets of hotwords. If the combined set exceeds 2,000 hotwords, it uses 2,000 selected at random.
Response body
request_idstringThe unique identifier of this request.
outputobjectThe output result.
sentenceobjectThe details of the current sentence.
sentence_idintegerThe sentence number, starting from 1.
begin_timeintegerThe start time of the sentence, in milliseconds.
end_timeinteger | nullSentence end time in milliseconds. Read the timestamp when sentence_end is true.
textstringThe recognized text of the current sentence.
channel_idintegerThe channel number, starting from 0.
speaker_idinteger | nullNoteOnly qwen-audio-3.1-asr-flash supports speaker diarization.
Speaker ID when diarization is enabled. When disabled, the field can be absent or null.
sentence_endbooleanWhether recognition of the current sentence is complete.
true— The sentence has ended. For qwen-audio-3.0-asr-flash, word timestamps are now final.false— The sentence is in progress. Later events can update its text and timestamps.
wordsarray[object]The list of word-level timestamps.
begin_timeintegerThe start time of the word, in milliseconds.
end_timeintegerThe end time of the word, in milliseconds.
textstringThe word text.
punctuationstringThe punctuation mark after the word. An empty string when there is no punctuation.
fixedbooleanWhether the word timestamp is final. Use this field with qwen-audio-3.1-asr-flash when speaker diarization is disabled.
true— The word timestamp is final.false— Later events can update the timestamp.
speaker_idinteger | nullNoteOnly qwen-audio-3.1-asr-flash supports speaker diarization.
The ID of the speaker for this word. Contains an ID when speaker diarization is enabled, and is null otherwise.
textstringThe full recognized text accumulated so far.
sentencesarray[object]NoteApplies only to qwen-audio-3.1-asr-flash.
Returned when speaker diarization is enabled. Contains recognition results for the current and previous sentences. Each element has the same structure as sentence.
usageobjectUsage is returned when the current sentence ends. Intermediate results can omit this field.
Note
- qwen-audio-3.0-asr-flash is billed by audio duration (
duration). - qwen-audio-3.1-asr-flash is billed by input and output tokens (
input_tokensandoutput_tokens) and also returnsdurationandtotal_tokens.
durationintegerThe processed audio duration, in seconds.
input_tokensintegerThe number of input tokens consumed by this request.
output_tokensintegerThe number of output tokens consumed by this request.
total_tokensintegerThe total number of tokens consumed by this request, equal to the sum of input_tokens and output_tokens.
Non-streaming
curl "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: disable" \
--data '{
"model": "qwen-audio-3.1-asr-flash",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/en/audios/6a4b3c2d1e0f9092.wav"}
}
]
}
]
},
"parameters": {
"format": "wav",
"sample_rate": "16000"
}
}'
{
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 120,
"end_time": 3782,
"text": "Please send the quarterly project report to Kellira before Friday. ",
"channel_id": 0,
"sentence_end": true,
"words": [
{"begin_time": 120, "end_time": 320, "text": "Please", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 320, "end_time": 560, "text": " send", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 560, "end_time": 760, "text": " the", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 760, "end_time": 1360, "text": " quarterly", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 1360, "end_time": 1800, "text": " project", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 1800, "end_time": 2080, "text": " report", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2080, "end_time": 2280, "text": " to", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2280, "end_time": 2336, "text": " ", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2336, "end_time": 2560, "text": "Kell", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2560, "end_time": 2800, "text": "ira", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2800, "end_time": 3160, "text": " before", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 3160, "end_time": 3782, "text": " Friday", "punctuation": ". ", "fixed": true, "speaker_id": null}
]
},
"text": "Please send the quarterly project report to Kellira before Friday. "
},
"usage": {
"duration": 4,
"input_tokens": 48,
"output_tokens": 13,
"total_tokens": 61
},
"request_id": "da820bb1-18da-9517-9568-2e74815df9cb"
}
Streaming (SSE)
curl --no-buffer "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: enable" \
--data '{
"model": "qwen-audio-3.1-asr-flash",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/en/audios/6a4b3c2d1e0f9092.wav"}
}
]
}
]
},
"parameters": {
"format": "wav",
"sample_rate": "16000"
}
}'
data:{"output":{"sentence":{"sentence_id":1,"begin_time":120,"end_time":null,"text":"Please send the quarterly project report to Kellira before","channel_id":0,"sentence_end":false,"words":[{"begin_time":120,"end_time":320,"text":"Please","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":320,"end_time":560,"text":" send","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":560,"end_time":760,"text":" the","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":760,"end_time":1360,"text":" quarterly","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":1360,"end_time":1800,"text":" project","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":1800,"end_time":2080,"text":" report","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":2080,"end_time":2280,"text":" to","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":2280,"end_time":2336,"text":" ","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":2336,"end_time":2560,"text":"Kell","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":2560,"end_time":2800,"text":"ira","punctuation":"","fixed":false,"speaker_id":null},{"begin_time":2800,"end_time":3160,"text":" before","punctuation":"","fixed":false,"speaker_id":null}]},"text":"Please send the quarterly project report to Kellira before"},"request_id":"c1c79784-7dfc-9312-b8bb-c9aa38929419"}
data:{"output":{"sentence":{"sentence_id":1,"begin_time":120,"end_time":3782,"text":"Please send the quarterly project report to Kellira before Friday. ","channel_id":0,"sentence_end":true,"words":[{"begin_time":120,"end_time":320,"text":"Please","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":320,"end_time":560,"text":" send","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":560,"end_time":760,"text":" the","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":760,"end_time":1360,"text":" quarterly","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":1360,"end_time":1800,"text":" project","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":1800,"end_time":2080,"text":" report","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":2080,"end_time":2280,"text":" to","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":2280,"end_time":2336,"text":" ","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":2336,"end_time":2560,"text":"Kell","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":2560,"end_time":2800,"text":"ira","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":2800,"end_time":3160,"text":" before","punctuation":"","fixed":true,"speaker_id":null},{"begin_time":3160,"end_time":3782,"text":" Friday","punctuation":". ","fixed":true,"speaker_id":null}]},"text":"Please send the quarterly project report to Kellira before Friday. "},"usage":{"duration":4,"input_tokens":48,"output_tokens":13,"total_tokens":61},"request_id":"c1c79784-7dfc-9312-b8bb-c9aa38929419"}
With context
curl "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: disable" \
--data '{
"model": "qwen-audio-3.1-asr-flash",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "The project manager is named Kelira."
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "I will use Kelira in the report."
}
]
},
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/en/audios/6a4b3c2d1e0f9092.wav"}
}
]
}
]
},
"parameters": {
"format": "wav",
"sample_rate": "16000"
}
}'
{
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 120,
"end_time": 3782,
"text": "Please send the quarterly project report to Kelira before Friday. ",
"channel_id": 0,
"sentence_end": true,
"words": [
{"begin_time": 120, "end_time": 320, "text": "Please", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 320, "end_time": 560, "text": " send", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 560, "end_time": 760, "text": " the", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 760, "end_time": 1360, "text": " quarterly", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 1360, "end_time": 1800, "text": " project", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 1800, "end_time": 2080, "text": " report", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2080, "end_time": 2280, "text": " to", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2280, "end_time": 2560, "text": " Kel", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2560, "end_time": 2800, "text": "ira", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 2800, "end_time": 3160, "text": " before", "punctuation": "", "fixed": true, "speaker_id": null},
{"begin_time": 3160, "end_time": 3782, "text": " Friday", "punctuation": ". ", "fixed": true, "speaker_id": null}
]
},
"text": "Please send the quarterly project report to Kelira before Friday. "
},
"usage": {
"duration": 4,
"input_tokens": 70,
"output_tokens": 12,
"total_tokens": 82
},
"request_id": "744974e3-ada7-94be-9950-a7a360220756"
}
Speaker diarization
curl "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: disable" \
--data '{
"model": "qwen-audio-3.1-asr-flash",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/en/audios/6a4b3c2d1e0f9092.wav"}
}
]
}
]
},
"parameters": {
"format": "wav",
"sample_rate": "16000",
"speaker_diarization_enabled": true
}
}'
{
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 0,
"end_time": 3680,
"text": "Please send the quarterly project report to Keller before Friday. ",
"channel_id": 0,
"speaker_id": 0,
"sentence_end": true,
"words": [
{"begin_time": 0, "end_time": 339, "text": "Please", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 339, "end_time": 622, "text": " send", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 622, "end_time": 849, "text": " the", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 849, "end_time": 1415, "text": " quarterly", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 1415, "end_time": 1868, "text": " project", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 1868, "end_time": 2264, "text": " report", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2264, "end_time": 2434, "text": " to", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2434, "end_time": 2830, "text": " Keller", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2830, "end_time": 3227, "text": " before", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 3227, "end_time": 3680, "text": " Friday", "punctuation": ". ", "fixed": true, "speaker_id": 0}
]
},
"text": "Please send the quarterly project report to Keller before Friday. ",
"sentences": [
{
"sentence_id": 1,
"begin_time": 0,
"end_time": 3680,
"text": "Please send the quarterly project report to Keller before Friday. ",
"channel_id": 0,
"speaker_id": 0,
"sentence_end": true,
"words": [
{"begin_time": 0, "end_time": 339, "text": "Please", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 339, "end_time": 622, "text": " send", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 622, "end_time": 849, "text": " the", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 849, "end_time": 1415, "text": " quarterly", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 1415, "end_time": 1868, "text": " project", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 1868, "end_time": 2264, "text": " report", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2264, "end_time": 2434, "text": " to", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2434, "end_time": 2830, "text": " Keller", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 2830, "end_time": 3227, "text": " before", "punctuation": "", "fixed": true, "speaker_id": 0},
{"begin_time": 3227, "end_time": 3680, "text": " Friday", "punctuation": ". ", "fixed": true, "speaker_id": 0}
]
}
]
},
"usage": {
"duration": 4,
"input_tokens": 48,
"output_tokens": 26,
"total_tokens": 74
},
"request_id": "9e272f37-1657-94bb-a3f2-0ca2e07015c1"
}