Skip to content

Qwen Speech Recognition ​

This API transcribes audio files into text. Audio can be provided as a public URL or a Base64 Data URI. The response supports sentence-level and word-level timestamps, context enhancement, hotwords, and speaker diarization.

Endpoint ​

http
POST /v1/audio/transcriptions

Authentication ​

MethodDescription
Bearer TokenPass Authorization: Bearer <API Key> in the request header to authenticate your account.

Request Headers ​

ParameterTypeRequiredDescription
Content-TypestringYesMedia type of the request body. Set to application/json.
AuthorizationstringYesBearer API Key used to authenticate your account.
X-DashScope-SSEstringNoWhether to return results as an SSE stream: enable to enable, disable to disable (default).

Note: This API accepts JSON request bodies only. multipart/form-data file uploads are not supported and return a 400 error. Provide the audio via an audio URL or a Base64 Data URI.

Request Body ​

ParameterTypeRequiredDefaultDescription
modelstringYes-Model ID. See the supported model list at the end of this page.
inputobjectYes-Input information. See "input Parameters".
parametersobjectYes-Model parameters. See "parameters Parameters".

input Parameters ​

ParameterTypeRequiredDefaultDescription
input.messagesarray<object>Yes-Message list containing the audio to transcribe and optional conversation context. Must contain at least one message of type input_audio.

messages Element ​

ParameterTypeRequiredDefaultDescription
rolestringYes-Message role: user or assistant. assistant is used only for context.
contentarray<object>Yes-List of message content items.

content Element ​

ParameterTypeRequiredDefaultDescription
typestringYes-Content type: input_audio, input_text, or text.
input_audioobjectNo-Required when type is input_audio.
textstringNo-Required when type is input_text or text.

input_audio Object ​

ParameterTypeRequiredDefaultDescription
input_audio.datastringYes-Audio file URL, or a Base64 Data URI in the format data:{MIME_TYPE};base64,{BASE64_DATA}.

parameters Parameters ​

ParameterTypeRequiredDefaultDescription
parameters.formatstringYes-Audio format. Must match the actual audio format, such as wav, mp3, or opus.
parameters.sample_ratestringNo-Audio sample rate in Hz. For example, 16000 means 16 kHz.
parameters.vocabulary_idstringNo-ID of a precompiled hotword list. This feature is not currently supported on the platform. Use inline hotwords (vocabulary) instead.
parameters.vocabularyobjectNo-Inline hotwords. Keys are hotword text and values are weights. See "Hotwords".
parameters.language_hintsarray<string>No-Language codes to recognize. Up to 4 values; if more are provided, only the first 4 take effect. If omitted, the model detects the language automatically.
parameters.speaker_diarization_enabledbooleanNofalseWhether to enable speaker diarization. Only supported by qwen-audio-3.1-asr-flash. When enabled, speakers are distinguished by speaker_id and output.sentences is returned; keep_dialect and language_hints do not take effect in this mode.
parameters.keep_dialectbooleanNofalseWhether to keep dialect expressions. Only supported by qwen-audio-3.1-asr-flash. When false, dialect is transcribed as Mandarin.

Audio Input Requirements ​

  • A single audio file must not exceed 10 MB or 5 minutes.
  • Audio can be provided as a publicly accessible audio URL or a Base64 Data URI.
  • The Base64 Data URI format is data:{MIME_TYPE};base64,{BASE64_DATA}. The MIME type must match the audio format, for example audio/wav for WAV and audio/mpeg for MP3.
  • Base64 encoding increases the payload size. Keep the original file small enough that the encoded data still meets the 10 MB input limit.
  • Formats such as wav, mp3, and opus are supported. The actual supported range is subject to the model audio specification.

Context Enhancement ​

Context fields improve recognition accuracy for domain-specific terms. You can pass previous conversation turns:

  • At most 5 context messages of each type (input_text and text). If more are provided, only the most recent 5 are kept.
  • The total context text length per turn (the sum of the text fields of user and assistant) must not exceed 400 characters. Excess content is truncated from the end.
  • Messages must be arranged in conversation turns: within each turn, user (input_text) must precede the corresponding assistant (text). The user message containing input_audio must be the last item in the messages array.

Hotwords ​

Note: The platform currently supports inline hotwords (vocabulary) but does not support precompiled hotwords (vocabulary_id).

  • vocabulary_id: ID of a precompiled hotword list. This feature is not currently supported on the platform. Use inline hotwords (vocabulary) instead.
  • vocabulary: Inline hotwords passed as key-value pairs. No precompiled list is required. Suitable for temporary, session-level optimization.
  • A weight in [1, 5] means the model is more likely to output the term as the value increases. A weight of 50 marks a super hotword with significantly improved recall. At most 50 super hotwords are allowed.
  • When both hotword types are configured, they are merged. If the merged count exceeds 2000, 2000 are selected at random. Since the platform does not currently support precompiled hotwords, only inline hotwords take effect in practice.
  • Inline hotwords are supported only by qwen-audio-3.1-asr-flash and qwen-audio-3.0-asr-flash.

Supported Language Codes ​

CodeLanguageCodeLanguageCodeLanguage
zhChineseenEnglishjaJapanese
koKoreanviVietnamesethThai
idIndonesianmsMalaytlFilipino
hiHindiarArabicfrFrench
deGermanesSpanishptPortuguese
ruRussianitItaliannlDutch
svSwedishdaDanishfiFinnish
noNorwegianelGreekplPolish
csCzechhuHungarianroRomanian
bgBulgarianhrCroatianskSlovak

Model Differences ​

ModelSpeaker DiarizationKeep DialectInline HotwordsUsage Fields
qwen-audio-3.1-asr-flashSupportedSupportedSupportedusage.duration, usage.input_tokens, usage.output_tokens, usage.total_tokens
qwen-audio-3.0-asr-flashNot supportedNot supportedSupportedusage.duration

Request Example ​

bash
curl --location --request POST 'https://neolink.com/api/v1/audio/transcriptions' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "qwen-audio-3.0-asr-flash",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "type": "input_audio",
                             "input_audio": {
                                 "data": "https://example.com/audio/sample.wav"
                             }
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "format": "wav",
             "sample_rate": "16000"
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/audio/transcriptions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}
payload = {
    "model": "qwen-audio-3.0-asr-flash",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": "https://example.com/audio/sample.wav"
                        }
                    }
                ]
            }
        ]
    },
    "parameters": {
        "format": "wav",
        "sample_rate": "16000"
    }
}
response = requests.post(url, headers=headers, json=payload, timeout=60)
print(response.json())
javascript
import https from 'https'

const data = JSON.stringify({
  model: 'qwen-audio-3.0-asr-flash',
  input: {
    messages: [
      {
        role: 'user',
        content: [
          {
            type: 'input_audio',
            input_audio: {
              data: 'https://example.com/audio/sample.wav'
            }
          }
        ]
      }
    ]
  },
  parameters: {
    format: 'wav',
    sample_rate: '16000'
  }
})

const req = https.request('https://neolink.com/api/v1/audio/transcriptions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API Key>',
    'Content-Length': Buffer.byteLength(data)
  }
}, res => {
  let body = ''
  res.on('data', chunk => body += chunk)
  res.on('end', () => console.log(JSON.parse(body)))
})
req.write(data)
req.end()

Streaming ​

Set X-DashScope-SSE: enable in the request header to enable streaming.

bash
curl --location --request POST 'https://neolink.com/api/v1/audio/transcriptions' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'X-DashScope-SSE: enable' \
     --data-raw '{
         "model": "qwen-audio-3.0-asr-flash",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "type": "input_audio",
                             "input_audio": {
                                 "data": "https://example.com/audio/sample.wav"
                             }
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "format": "wav",
             "sample_rate": "16000"
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/audio/transcriptions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
    "X-DashScope-SSE": "enable",
}
payload = {
    "model": "qwen-audio-3.0-asr-flash",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {
                            "data": "https://example.com/audio/sample.wav"
                        }
                    }
                ]
            }
        ]
    },
    "parameters": {
        "format": "wav",
        "sample_rate": "16000"
    }
}

with requests.post(url, headers=headers, json=payload, stream=True, timeout=300) as response:
    for raw_line in response.iter_lines():
        if not raw_line:
            continue
        line = raw_line.decode("utf-8")
        if not line.startswith("data:"):
            continue
        print(line[len("data:"):].strip())

Using Base64 Audio ​

python
import base64
import pathlib

import requests

audio_path = pathlib.Path("sample.wav")
data_uri = "data:audio/wav;base64," + base64.b64encode(audio_path.read_bytes()).decode()

url = "https://neolink.com/api/v1/audio/transcriptions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}
payload = {
    "model": "qwen-audio-3.0-asr-flash",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "input_audio",
                        "input_audio": {"data": data_uri}
                    }
                ]
            }
        ]
    },
    "parameters": {
        "format": "wav",
        "sample_rate": "16000"
    }
}
response = requests.post(url, headers=headers, json=payload, timeout=60)
print(response.json())

Context Enhancement Example ​

bash
curl --location --request POST 'https://neolink.com/api/v1/audio/transcriptions' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "qwen-audio-3.0-asr-flash",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "type": "input_text",
                             "text": "Hello"
                         }
                     ]
                 },
                 {
                     "role": "assistant",
                     "content": [
                         {
                             "type": "text",
                             "text": "Hello, I am Qwen. How can I help you?"
                         }
                     ]
                 },
                 {
                     "role": "user",
                     "content": [
                         {
                             "type": "input_audio",
                             "input_audio": {
                                 "data": "https://example.com/audio/sample.wav"
                             }
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "format": "wav",
             "sample_rate": "16000"
         }
     }'

Inline Hotwords Example ​

bash
curl --location --request POST 'https://neolink.com/api/v1/audio/transcriptions' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "qwen-audio-3.0-asr-flash",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "type": "input_audio",
                             "input_audio": {
                                 "data": "https://example.com/audio/sample.wav"
                             }
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "format": "wav",
             "sample_rate": "16000",
             "vocabulary": {
                 "Alice": 5,
                 "Bob": 5
             }
         }
     }'

Response Body ​

ParameterTypeDescription
request_idstringUnique identifier of the request
output.textstringComplete transcription text accumulated so far
output.sentenceobjectDetails of the current sentence
output.sentence.speaker_idinteger / nullSpeaker ID. Returned only when qwen-audio-3.1-asr-flash has speaker diarization enabled; otherwise null.
output.sentence.sentence_idintegerSentence ID, starting from 1
output.sentence.sentence_endbooleanWhether this is the final result for the sentence. true means the sentence is complete.
output.sentence.begin_timeintegerSentence start time in milliseconds
output.sentence.end_timeintegerSentence end time in milliseconds. Returned only when sentence_end is true.
output.sentence.textstringTranscription text of the current sentence
output.sentence.channel_idintegerChannel ID, starting from 0
output.sentence.wordsarray<object>Word-level timestamp list
output.sentence.words[].speaker_idinteger / nullSpeaker ID of the word. Returned only when qwen-audio-3.1-asr-flash has speaker diarization enabled; otherwise null.
output.sentence.words[].textstringWord text
output.sentence.words[].begin_timeintegerWord start time in milliseconds
output.sentence.words[].end_timeintegerWord end time in milliseconds
output.sentence.words[].punctuationstringPunctuation following the word. Empty string if there is none.
output.sentence.words[].fixedbooleanWhether the word is stable. false means the timestamp may change in subsequent events.
output.sentencesarray<object>Current and historical sentence results. Each element has the same structure as output.sentence. Returned only when qwen-audio-3.1-asr-flash has speaker diarization enabled.
usage.durationintegerProcessed audio duration in seconds. Returned only when sentence_end is true.
usage.input_tokensintegerInput tokens consumed by this request. Returned only by qwen-audio-3.1-asr-flash.
usage.output_tokensintegerOutput tokens consumed by this request. Returned only by qwen-audio-3.1-asr-flash.
usage.total_tokensintegerTotal tokens consumed, equal to input_tokens plus output_tokens. Returned only by qwen-audio-3.1-asr-flash.

Response Example ​

json
{
  "output": {
    "sentence": {
      "begin_time": 760,
      "channel_id": 0,
      "end_time": 3800,
      "sentence_end": true,
      "sentence_id": 1,
      "text": "Hello World,这里是阿里巴巴语音实验室。",
      "words": [
        {
          "begin_time": 760,
          "end_time": 1040,
          "fixed": true,
          "punctuation": "",
          "text": "Hello"
        },
        {
          "begin_time": 1040,
          "end_time": 1240,
          "fixed": true,
          "punctuation": ",",
          "text": " World"
        },
        {
          "begin_time": 1360,
          "end_time": 1880,
          "fixed": true,
          "punctuation": "",
          "text": "这里是"
        },
        {
          "begin_time": 1880,
          "end_time": 2520,
          "fixed": true,
          "punctuation": "",
          "text": "阿里巴巴"
        },
        {
          "begin_time": 2520,
          "end_time": 2840,
          "fixed": true,
          "punctuation": "",
          "text": "语音"
        },
        {
          "begin_time": 2840,
          "end_time": 3800,
          "fixed": true,
          "punctuation": "。",
          "text": "实验室"
        }
      ]
    },
    "text": "Hello World,这里是阿里巴巴语音实验室。"
  },
  "usage": {
    "duration": 4
  },
  "request_id": "40e0734d-096f-9ae3-86c1-a8c013287561"
}

Note: Some upstream versions may nest sentence information under output.output.sentence. Regardless of the structure, the complete transcription text is always available in output.text.

Streaming Response ​

When X-DashScope-SSE: enable is set in the request header, the server returns recognition results over Server-Sent Events (SSE). Intermediate and final results are returned in multiple events only when the audio is at least 1 minute long.

Upstream SSE event format:

plaintext
id:{sequence number}
event:result
:HTTP_STATUS/200
data:{JSON data}

Upstream example:

plaintext
id:1
event:result
:HTTP_STATUS/200
data:{"output":{"sentence":{"sentence_id":1,"sentence_end":true,"end_time":3800,"words":[{"end_time":1040,"punctuation":"","begin_time":760,"fixed":true,"text":"Hello"},{"end_time":1240,"punctuation":",","begin_time":1040,"fixed":true,"text":" World"},{"end_time":1880,"punctuation":"","begin_time":1360,"fixed":true,"text":"这里是"},{"end_time":2520,"punctuation":"","begin_time":1880,"fixed":true,"text":"阿里巴巴"},{"end_time":2840,"punctuation":"","begin_time":2520,"fixed":true,"text":"语音"},{"end_time":3800,"punctuation":"。","begin_time":2840,"fixed":true,"text":"实验室"}],"begin_time":760,"text":"Hello World,这里是阿里巴巴语音实验室。","channel_id":0},"text":"Hello World,这里是阿里巴巴语音实验室。"},"usage":{"duration":4},"request_id":"fc1582e4-935c-9fc2-a482-a98bf43daa69"}

When forwarded through the gateway, control lines such as id and event are filtered out. Clients only need to parse the JSON in each data: line.

Processing notes:

  1. For each SSE event, parse the JSON in the data field.
  2. Use output.sentence.sentence_end to determine whether the current sentence is complete: true means the sentence is finished and word-level timestamps are stable, so it can be used as the final result; false means recognition is still in progress and the text and timestamps may be updated in subsequent events.
  3. usage is returned only in sentence-end events and can be used to measure the processed audio duration.
  4. When qwen-audio-3.1-asr-flash has speaker diarization enabled, read output.sentences for current and historical sentence results.

Supported Models ​

Supported Models:

  • qwen-audio-3.1-asr-flash
  • qwen-audio-3.0-asr-flash