Qwen-Audio-ASR HTTP API

Updated at:

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.

POSThttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

Request headers

AuthorizationstringRequired

Use the API key for the endpoint region, in the format Bearer <API Key>.

Content-TypestringRequired

The media type of the request body. Fixed to application/json.

X-DashScope-SSEstringOptional

Controls how the result is returned.

  • enable — Requests a streaming response. Parse the response according to its Content-Type.
    • text/event-stream — Read each SSE event and parse the content after data: as JSON.
    • application/json — Parse the entire response as a single JSON object.
  • disable or 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

modelstringRequired

The model name.

inputobjectRequired

The input information.

messagesarray[object]Required

List of messages. Optional conversation history precedes the audio. The user message containing the audio must come last.

rolestringRequired

Message 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]Required

The message content list.

typestringRequired

Choose the content type for the message role. Include at least one input_audio item per request.

  • input_audio — Audio from user. Requires an input_audio object.
  • input_text — Context from user. Requires the text field.
  • text — Context from assistant. Requires the text field.
input_audioobjectConditionally required

Required when type is input_audio.

datastringRequired

Audio 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, use audio/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 required

Context 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_text and text). If this limit is exceeded, only the 5 most recent messages are kept.
  • Text length: The combined length of the user and assistant text fields 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 user message (input_text) must precede its corresponding assistant message (text).
parametersobjectRequired

The model parameters.

formatstringRequired

The audio format. Set this to match your actual audio format. Supported values include wav, mp3, and opus. For details, see Audio specifications.

sample_ratestringOptional

The audio sample rate, in Hz. For example, 16000 means a 16 kHz sample rate. For details, see Audio specifications.

speaker_diarization_enabledbooleanOptional

NoteApplies 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_dialectbooleanOptional

NoteApplies 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]Optional

Specify 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: Chinese
  • en: English
  • ja: Japanese
  • ko: Korean
  • vi: Vietnamese
  • th: Thai
  • id: Indonesian
  • ms: Malay
  • tl: Filipino
  • hi: Hindi
  • ar: Arabic
  • fr: French
  • de: German
  • es: Spanish
  • pt: Portuguese
  • ru: Russian
  • it: Italian
  • nl: Dutch
  • sv: Swedish
  • da: Danish
  • fi: Finnish
  • no: Norwegian
  • el: Greek
  • pl: Polish
  • cs: Czech
  • hu: Hungarian
  • ro: Romanian
  • bg: Bulgarian
  • hr: Croatian
  • sk: Slovak

qwen-audio-3.1-asr-flash also supports the following language codes:

  • tr: Turkish
  • fa: Persian
  • mr: Marathi
  • ml: Malayalam
  • ne: Nepali
  • ky: Kyrgyz
  • az: Azerbaijani
  • ka: Georgian
  • hy: Armenian
  • sl: Slovenian
  • sq: Albanian
  • et: Estonian
  • lv: Latvian
  • lt: Lithuanian
  • ca: Catalan
  • eu: Basque
  • gl: Galician
  • or: Odia
  • dv: Divehi
  • as: Assamese
  • kmr: Northern Kurdish
  • tig: Tigre
  • fy: Western Frisian
  • ba: Bashkir
  • be: Belarusian
  • tt: Tatar
  • ia: Interlingua
  • mhr: Meadow Mari
  • tok: Toki Pona
vocabulary_idstringOptional

The 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.

vocabularyobjectOptional

Use 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_idstring

The unique identifier of this request.

outputobject

The output result.

sentenceobject

The details of the current sentence.

sentence_idinteger

The sentence number, starting from 1.

begin_timeinteger

The start time of the sentence, in milliseconds.

end_timeinteger | null

Sentence end time in milliseconds. Read the timestamp when sentence_end is true.

textstring

The recognized text of the current sentence.

channel_idinteger

The channel number, starting from 0.

speaker_idinteger | null

NoteOnly 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_endboolean

Whether 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_timeinteger

The start time of the word, in milliseconds.

end_timeinteger

The end time of the word, in milliseconds.

textstring

The word text.

punctuationstring

The punctuation mark after the word. An empty string when there is no punctuation.

fixedboolean

Whether 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 | null

NoteOnly 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.

textstring

The 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.

usageobject

Usage 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_tokens and output_tokens) and also returns duration and total_tokens.
durationinteger

The processed audio duration, in seconds.

input_tokensinteger

The number of input tokens consumed by this request.

output_tokensinteger

The number of output tokens consumed by this request.

total_tokensinteger

The 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"
}